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

/guide/components/events.md #2300

Open
freemedom opened this issue Mar 24, 2023 · 1 comment
Open

/guide/components/events.md #2300

freemedom opened this issue Mar 24, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@freemedom
Copy link
Contributor

freemedom commented Mar 24, 2023

Although optional, it is recommended to define all emitted events in order to better document how a component should work. It also allows Vue to exclude known listeners from [fallthrough attributes](/guide/components/attrs#v-on-listener-inheritance), avoiding edge cases caused by DOM events manually dispatched by 3rd party code.

avoiding edge cases caused by DOM events manually dispatched by 3rd party code


vuejs/core#27

The problem is that these same listeners can also be triggered by custom events - in the above example, both a native click event and a custom one emitted by this.$emit('click') in the child will trigger the parent's foo handler. This may lead to unwanted behavior.

I don't quite understand why edge cases are caused by 3rd party code manually dispatch event?
If declare the events in emits option, should the events only manually dispatched by code be the target's behavior?

@skirtles-code
Copy link
Contributor

I don't really understand what that means either. I'm not sure it's necessary to mention that edge case to explain the emits option.

@skirtles-code skirtles-code added the enhancement New feature or request label Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants