Skip to content

in operator not working correctly with component instance exposeProxy #6137

@DrJume

Description

@DrJume

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

  1. Create a component which uses expose({...}) in the setup() function.
  2. Use this component in another Vue component and use a template ref to access its instance.
  3. Access templateRef.value in the mounted hook.

What is expected?

templateRef.value.$el // should evaluate to the HTML node correctly
'$el' in templateRef.value // should be true

What 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?

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

No one assigned

    Labels

    🐞 bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions