Skip to content

Commit 2787c34

Browse files
authored
fix(reactivity): use isExtensible instead of isFrozen (#1753)
close #1784
1 parent 3692f27 commit 2787c34

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

packages/reactivity/__tests__/reactive.spec.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,16 @@ describe('reactivity/reactive', () => {
183183
expect(isReactive(obj.bar)).toBe(false)
184184
})
185185

186-
test('should not observe frozen objects', () => {
186+
test('should not observe non-extensible objects', () => {
187187
const obj = reactive({
188-
foo: Object.freeze({ a: 1 })
188+
foo: Object.preventExtensions({ a: 1 }),
189+
// sealed or frozen objects are considered non-extensible as well
190+
bar: Object.freeze({ a: 1 }),
191+
baz: Object.seal({ a: 1 })
189192
})
190193
expect(isReactive(obj.foo)).toBe(false)
194+
expect(isReactive(obj.bar)).toBe(false)
195+
expect(isReactive(obj.baz)).toBe(false)
191196
})
192197

193198
test('should not observe objects with __v_skip', () => {

packages/reactivity/src/reactive.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const canObserve = (value: Target): boolean => {
3939
return (
4040
!value[ReactiveFlags.SKIP] &&
4141
isObservableType(toRawType(value)) &&
42-
!Object.isFrozen(value)
42+
Object.isExtensible(value)
4343
)
4444
}
4545

0 commit comments

Comments
 (0)