Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
$emit poorly documented / breaks platform patterns #9868
It is largely a documentation issue / missing feature, so linking to the relevant JS Event spec on MDN.
Steps to reproduce
Call $emit('my-event') on a component while listening for it on a grandparent component.
What is expected?
I expect to be able to fire an event that is able to say "this event should bubble until stopped" and likewise, fire an event that is not cancellable as per the JS specs.
What is actually happening?
There is no way to do this in Vue presently.
Can you explain the design choice because it's never been explained in any of the closed tickets? Infact the handling of this broken standard has been nothing more than "we know" or "by design" how is anyone supposed to suggest an improvement when the people who know the reasoning never elaborate on that reasoning?
The docs never said custom events behave like native events. They are modeled after Node.js' EventEmitter. The docs never claimed custom events are anything similar to native DOM events, in fact, it explicitly warns you that they are different concepts.
The deprecated option was
@yyx990803 That is certainly more useful information, considering the docs call the feature