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

Listeners declared in emits array are inacessible #4713

Closed
aleksander237 opened this issue Sep 30, 2021 · 3 comments
Closed

Listeners declared in emits array are inacessible #4713

aleksander237 opened this issue Sep 30, 2021 · 3 comments

Comments

@aleksander237
Copy link

Version

3.2.19

Reproduction link

sfc.vuejs.org/

Steps to reproduce

Uncomment the emits array declaration in VirtualForm component

What is expected?

Refering to the documentation: https://v3.vuejs.org/guide/migration/listeners-removed.html, the listeners should be available as keys of the this.$attrs object

What is actually happening?

The listeners are not available.

@posva
Copy link
Member

posva commented Sep 30, 2021

By defining the emits, you ensure they are not passed to $attrs. This is intentional.

@posva posva closed this as completed Sep 30, 2021
@aleksander237
Copy link
Author

Thanks for quick response.

My point is that all undeclared properties are available in the $attrs. As soon as the property is declared it is available somwhere else, but with the listeners declaration (including in emits) makes a listener "unaccessible". So what is the solution here? Should I simply exclude listener from emits if I want to acess it somewhere in the code? Is it "safe"? - because vue emits the warning.

@posva
Copy link
Member

posva commented Oct 1, 2021

In order to check if it exists, you should declare it as a prop: vuejs/rfcs#154 (comment)

@github-actions github-actions bot locked and limited conversation to collaborators Oct 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants