-
-
Notifications
You must be signed in to change notification settings - Fork 9k
Closed
Labels
🐞 bugSomething isn't workingSomething isn't working
Description
Vue version
3.2.37
Link to minimal reproduction
https://stackblitz.com/edit/vuejs-issue-repro-in-operator-expose-proxy?file=src%2FApp.vue
Steps to reproduce
- Create a component which uses
expose({...})in thesetup()function. - Use this component in another Vue component and use a template ref to access its instance.
- Access
templateRef.valuein the mounted hook.
What is expected?
templateRef.value.$el // should evaluate to the HTML node correctly'$el' in templateRef.value // should be trueWhat is actually happening?
templateRef.value.$el // evaluates to the HTML node correctly ✅'$el' in templateRef.value // is false ❌System Info
No response
Any additional comments?
core/packages/runtime-core/src/component.ts
Lines 934 to 949 in 25f7a16
| export function getExposeProxy(instance: ComponentInternalInstance) { | |
| if (instance.exposed) { | |
| return ( | |
| instance.exposeProxy || | |
| (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), { | |
| get(target, key: string) { | |
| if (key in target) { | |
| return target[key] | |
| } else if (key in publicPropertiesMap) { | |
| return publicPropertiesMap[key](instance) | |
| } | |
| } | |
| })) | |
| ) | |
| } | |
| } |
I suspect that the exposeProxy which uses the get() handler needs to implement the same logic in the Proxy's has() handler to fallback to checking if the checked property is defined in publicPropertiesMap[key](instance).
Metadata
Metadata
Assignees
Labels
🐞 bugSomething isn't workingSomething isn't working