-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Methods exposed with defineExpose are not available on custom element #5540
Comments
Is there anything in the docs for defineCusromElement giving you the impression that they should be? I don't think we planned for that, it's simply not supported. We don't expose anything about the component on the custom element wrapper except its props. |
I was just following this documentation and assumed that if Either way if it's like a triage issue how can we turn this into feature? |
I think it's useful for expose to allow certain things to be exposed, such as' input.click() ', which I currently handle with object.defineProperty |
I too have this problem but I got to say that it's not consistent. Some components work and other don't. I can't put a finger on a reason why. They all use It seems to affect components that are conditionally rendered via a |
I stand corrected. See below. |
@m-ghaoui even though I created this issue I can see how this is simply a new feature :) for time being I use this composable to get to the host:
and inside your custom element you can expose your method with simple assignment:
|
Oh I get it now. Okay 🙂 I stand corrected. |
I created a PR @LinusBorg #6256 |
I confirm, it's been bugging me that why it works on one Component and not another. |
Are there any plans on adding this new feature? The PR from @LinusBorg is getting pretty old. |
facing the same issue, temporary workaround to access the exposed method via const myRef = ref()
// <myElement ref="myRef"></myElement>
myRef.value.$.exposed.ExposedMethod() |
Any progress on that over-a-year-old shortcoming of Vue's implementation of webcomponents? Is that ever going to land in Vue or should we just create and use a fork to get it implemented? |
Worked for me |
I cannot obtain exposed in myComponent.value._instance.exposed.xxx() vue2 and vue3 can be obtained through |
closed via #6256 |
Version
3.2.31
Reproduction link
stackblitz.com
Steps to reproduce
Open repro and you should see 'hello' in the console instead of
Uncaught TypeError: ce.value.hello is not a function
What is expected?
Methods exposed with
defineExpose
are available on given component instanceWhat is actually happening?
They are not exposed
The text was updated successfully, but these errors were encountered: