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

Can't have bubbling and capturing event listeners of the same event type on a element #1567

Closed
janispritzkau opened this issue Jul 11, 2020 · 2 comments

Comments

@janispritzkau
Copy link

janispritzkau commented Jul 11, 2020

Version

3.0.0-beta.20

Reproduction link

https://jsfiddle.net/janispritzkau/f4wdbm3r/17/

Steps to reproduce

Click on the element and check the console.

What is expected?

Both the regular bubbling and capture event listener should be added to the element and the handler functions should be called when the event is triggered.

What is actually happening?

The bubbling event listener works fine but the capturing event listener throws an error when triggered and the handler for it doesn't get called.


Here is how you would do this in Vue 2 in a render function:

h("div", {
  on: {
    "click": onClick,
    "!click": onClick
  }
})

The Vue 3 template compiler does something like this:

h("div", {
  onClick: [
    event => onClick(event),
    {
      handler: event => onClick(event),
      options: { capture: true }
    }
  ]
})
@janispritzkau janispritzkau changed the title Bubbling and capturing event listener of the same event type on element Bubbling and capturing event listeners of the same event type on a element Jul 11, 2020
@janispritzkau janispritzkau changed the title Bubbling and capturing event listeners of the same event type on a element Can't have bubbling and capturing event listeners of the same event type on a element Jul 12, 2020
@janispritzkau
Copy link
Author

janispritzkau commented Jul 12, 2020

I'm guessing the problem is that Vue can't take object event listener definitions as an array.

@janispritzkau
Copy link
Author

janispritzkau commented Jul 12, 2020

That's roughly how it could be fixed by iterating over both the previous and next values in the patchEvent function:
master...janispritzkau:multiple-event-listener-options

@github-actions github-actions bot locked and limited conversation to collaborators Nov 9, 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

1 participant