From 7edfdf7e239ef8f58a343f9802d675d84ed51d64 Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 22 Jul 2020 21:19:10 -0400 Subject: [PATCH] fix(reactivity): avoid tracking internal symbols in has trap fix #1683 --- packages/reactivity/__tests__/effect.spec.ts | 2 +- packages/reactivity/src/baseHandlers.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/reactivity/__tests__/effect.spec.ts b/packages/reactivity/__tests__/effect.spec.ts index 4e49a146..7285bb53 100644 --- a/packages/reactivity/__tests__/effect.spec.ts +++ b/packages/reactivity/__tests__/effect.spec.ts @@ -759,7 +759,7 @@ describe('reactivity/effect', () => { expect(fnSpy).toHaveBeenCalledTimes(1) }) - it('should trigger all effects when array length is set 0', () => { + it('should trigger all effects when array length is set to 0', () => { const observed: any = reactive([1]) let dummy, record effect(() => { diff --git a/packages/reactivity/src/baseHandlers.ts b/packages/reactivity/src/baseHandlers.ts index fbb18a22..6c0a1a44 100644 --- a/packages/reactivity/src/baseHandlers.ts +++ b/packages/reactivity/src/baseHandlers.ts @@ -142,7 +142,9 @@ function deleteProperty(target: object, key: string | symbol): boolean { function has(target: object, key: string | symbol): boolean { const result = Reflect.has(target, key) - track(target, TrackOpTypes.HAS, key) + if (!isSymbol(key) || !builtInSymbols.has(key)) { + track(target, TrackOpTypes.HAS, key) + } return result }