Skip to content

Registered events are missing in component instance #5220

Closed
@JohMun

Description

@JohMun

Version

3.2.26

Reproduction link

codesandbox.io

(For some reason codesandbox throws the error "Cannot use import statement outside a module" sometimes. Simply reload the page... 🤞)

Steps to reproduce

  1. Create a component and use it in another component
  2. Add an event listener to the child component e.g. @test="() => {}"
  3. In the mounted hook of the child component, add console.log(this)
  4. In this.$attrs onTest exists and we know, the parent listen to the event.
  5. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions