Skip to content

Commit

Permalink
correct enumerable default (#726)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-entin committed Oct 20, 2023
1 parent bc0bf6f commit 74bfb46
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/vanilla.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ const buildProxyFunction = (
return
}
const value = Reflect.get(target, key)
const { enumerable = true } =
Reflect.getOwnPropertyDescriptor(target, key) ?? {}
const { enumerable = false } =
Reflect.getOwnPropertyDescriptor(target, key) as PropertyDescriptor
const desc: PropertyDescriptor = {
value,
enumerable,
Expand Down
4 changes: 2 additions & 2 deletions tests/basic.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { StrictMode, useEffect, useRef, useState } from 'react'
import { fireEvent, render, waitFor } from '@testing-library/react'
import { proxy, useSnapshot, snapshot } from 'valtio'
import { expect, it, vi } from 'vitest'
import { proxy, snapshot, useSnapshot } from 'valtio'

it('simple counter', async () => {
const obj = proxy({ count: 0 })
Expand Down Expand Up @@ -495,6 +495,6 @@ it('sync snapshot between nested components (#460)', async () => {
})

it('respects property enumerability (#726)', async () => {
let x = proxy(Object.defineProperty({ a: 1 }, 'b', { value: 2 }))
const x = proxy(Object.defineProperty({ a: 1 }, 'b', { value: 2 }))
expect(Object.keys(snapshot(x))).toEqual(Object.keys(x))
})

0 comments on commit 74bfb46

Please sign in to comment.