Closed
Description
Version
3.2.26
Reproduction link
(For some reason codesandbox throws the error "Cannot use import statement outside a module" sometimes. Simply reload the page... 🤞)
Steps to reproduce
- Create a component and use it in another component
- Add an event listener to the child component e.g.
@test="() => {}"
- In the mounted hook of the child component, add
console.log(this)
- In
this.$attrs
onTest
exists and we know, the parent listen to the event. - If we add
emits: ['test']
in the child component options,onTest
is missing in$attrs
and we have no chance to detect if the parent uses the event.
What is expected?
I would expect a property called this.$events
containing all registered events. In vue 2 it was possible to access registered events with this._events['name']
What is actually happening?
If an event ist added to the emits
option of a component, there is no way to detect if the parent listen to the event or not.