]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(runtime-core): fix component public instance has check for accessed non-existent...
authorEvan You <yyx990803@gmail.com>
Thu, 25 Nov 2021 10:15:06 +0000 (18:15 +0800)
committerEvan You <yyx990803@gmail.com>
Thu, 25 Nov 2021 10:15:06 +0000 (18:15 +0800)
close #4962

packages/runtime-core/__tests__/componentPublicInstance.spec.ts
packages/runtime-core/src/componentPublicInstance.ts

index c4c456b5f7ae8b180187ace0db4201fe2344b837..0274351f8639f225d62974cd6dc3b2c0350fe5bd 100644 (file)
@@ -195,6 +195,11 @@ describe('component: proxy', () => {
     expect('$foobar' in instanceProxy).toBe(false)
     expect('baz' in instanceProxy).toBe(false)
 
+    // #4962 triggering getter should not cause non-existent property to
+    // pass the has check
+    instanceProxy.baz
+    expect('baz' in instanceProxy).toBe(false)
+
     // set non-existent (goes into proxyTarget sink)
     instanceProxy.baz = 1
     expect('baz' in instanceProxy).toBe(true)
index dd385a815c97ab9058991b44f6610f780c24145f..8298aff42b1114378833af76946abc6c3191438f 100644 (file)
@@ -248,11 +248,11 @@ if (__COMPAT__) {
 }
 
 const enum AccessTypes {
+  OTHER,
   SETUP,
   DATA,
   PROPS,
-  CONTEXT,
-  OTHER
+  CONTEXT
 }
 
 export interface ComponentRenderContext {
@@ -437,7 +437,7 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
   ) {
     let normalizedProps
     return (
-      accessCache![key] !== undefined ||
+      !!accessCache![key] ||
       (data !== EMPTY_OBJ && hasOwn(data, key)) ||
       (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
       ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||