Skip to content
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

Equivalent for this.$listeners for native events? #9757

Open
DM2489 opened this issue Mar 22, 2019 · 5 comments
Open

Equivalent for this.$listeners for native events? #9757

DM2489 opened this issue Mar 22, 2019 · 5 comments

Comments

@DM2489
Copy link

DM2489 commented Mar 22, 2019

What problem does this feature solve?

Imagine a wrapper component where you need to pass events to a child component. This is possible for non native events using this.$listeners, but it strips out native events. It would be good if we had something like this.$nativeListeners so that we can pass native events down to child components as well.

In the meantime, Is there a workaround to pass events to child components?

What does the proposed API look like?

this.$nativeListeners

@posva
Copy link
Member

posva commented Mar 22, 2019

Maybe something like inheritNativeListeners: true (that default to false) to go in pair with inheritAttrs

Native listeners are available in functional components but are passed to the root of the component in regular components

@DM2489
Copy link
Author

DM2489 commented Mar 22, 2019

Thanks for the reply! Is there a workaround to get the native events out of the root?

@posva
Copy link
Member

posva commented Mar 22, 2019

not that i'm aware of

@sqal
Copy link
Contributor

sqal commented Mar 22, 2019

@DM2489

Is there a workaround to get the native events out of the root

You can access them in this.$vnode.data.nativeOn

@posva
Copy link
Member

posva commented Mar 22, 2019

Note they will still be bound to the root element though and that you should avoid reading $vnode in general and never modify it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants