]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(runtime-core): `in` operator returning `false` for built-in instance properties...
authorJulian Meinking <12785972+DrJume@users.noreply.github.com>
Wed, 26 Oct 2022 09:54:10 +0000 (11:54 +0200)
committerGitHub <noreply@github.com>
Wed, 26 Oct 2022 09:54:10 +0000 (05:54 -0400)
fix #6137

packages/runtime-core/__tests__/apiExpose.spec.ts
packages/runtime-core/src/component.ts

index 1235096b016e5912c49ca8a4592fe0003ed39f4a..1bfd513943bb9955aa63ceae6e5cbe0b1e9c694c 100644 (file)
@@ -203,7 +203,9 @@ describe('api: expose', () => {
         return h('div')
       },
       setup(_, { expose }) {
-        expose()
+        expose({
+          foo: 42
+        })
         return () => h(GrandChild, { ref: grandChildRef })
       }
     })
@@ -216,7 +218,10 @@ describe('api: expose', () => {
     }
     const root = nodeOps.createElement('div')
     render(h(Parent), root)
+    expect('$el' in childRef.value).toBe(true)
     expect(childRef.value.$el.tag).toBe('div')
+    expect('foo' in childRef.value).toBe(true)
+    expect('$parent' in grandChildRef.value).toBe(true)
     expect(grandChildRef.value.$parent).toBe(childRef.value)
     expect(grandChildRef.value.$parent.$parent).toBe(grandChildRef.value.$root)
   })
index c70a6f87411e350fdb81cdd39550abf526a563fb..68f10a669b3d0c64def4bffd6131336e3654970b 100644 (file)
@@ -945,6 +945,9 @@ export function getExposeProxy(instance: ComponentInternalInstance) {
           } else if (key in publicPropertiesMap) {
             return publicPropertiesMap[key](instance)
           }
+        },
+        has(target, key: string) {
+          return key in target || key in publicPropertiesMap
         }
       }))
     )