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

Multiple arguments in custom event with a modifier are not passed to handler #10867

Closed
osasson opened this issue Nov 26, 2019 · 2 comments · Fixed by #10958
Closed

Multiple arguments in custom event with a modifier are not passed to handler #10867

osasson opened this issue Nov 26, 2019 · 2 comments · Fixed by #10958

Comments

@osasson
Copy link

osasson commented Nov 26, 2019

Version

2.6.10

Reproduction link

https://jsfiddle.net/50wL7mdz/30115/

Steps to reproduce

Add a modifier to one of the event listeners. e.g. @emission.once

What is expected?

That all arguments will be passed to the function

What is actually happening?

Only the first argument is passed


My guess is that it lies in the template compiler which creates a function($event){...} and calling the handler with $event instead of ...arguments?

@posva
Copy link
Member

posva commented Nov 26, 2019

As a workaround you can use this version

  <component @emission.once="hearEmission('extra', ...arguments)">with extras, incomplete data</component>

The generated js code should be different: https://template-explorer.vuejs.org/#%3Cdiv%20id%3D%22app%22%3E%0A%20%20%3Ccomponent%20%40emission.once%3D%22hearEmission%22%3Ecomplete%20data%2C%20without%20extras%3C%2Fcomponent%3E%0A%20%20%3Ccomponent%20%40emission.once%3D%22hearEmission('extra'%2C%20...arguments)%22%3Ewith%20extras%2C%20incomplete%20data%3C%2Fcomponent%3E%0A%20%20%3Ccomponent%20%40emission.once%3D%22function%20(a%2C%20b%2C%20c)%20%7B%20hearEmission('extra'%2C%20a%2C%20b%2C%20c)%20%7D%22%3Eexpected%2C%20overly%20explicit%3C%2Fcomponent%3E%0A%20%20%0A%3C%2Fdiv%3E

The first one should be:

on: {
        "~emission": hearEmission
        }

The second one shouldn't change and the last one might be a bit more complicated as there should be quite a few edge cases but if we use an apply we should be able to keep a very similar version

@osasson
Copy link
Author

osasson commented Nov 27, 2019

Thanks for the quick response and for the link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants