Skip to content

Commit

Permalink
fix(runtime-core): in operator returning false for built-in insta…
Browse files Browse the repository at this point in the history
…nce properties in `exposeProxy` (vuejs#6138)

fix vuejs#6137
  • Loading branch information
DrJume authored and zhangzhonghe committed Apr 12, 2023
1 parent f77141c commit e703d60
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/runtime-core/__tests__/apiExpose.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ describe('api: expose', () => {
return h('div')
},
setup(_, { expose }) {
expose()
expose({
foo: 42
})
return () => h(GrandChild, { ref: grandChildRef })
}
})
Expand All @@ -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)
})
Expand Down
3 changes: 3 additions & 0 deletions packages/runtime-core/src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}))
)
Expand Down

0 comments on commit e703d60

Please sign in to comment.