fix(compiler-core): keep event handlers noninitial arguments #1265
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When the compiler encounters a template such as this
the function passed as the prop
onAnEvent
to<AComponent>
is generated like thisThis becomes a problem when the event is emitted with more than one argument. Only the first argument,
$event
, is passed to the event handler.This is especially evident when wanting to use the transition enter/leave's
resolve
function.This PR fixes this by replacing
$event
with($event, ...args)
in code generation for the vOn transform.Resulting in functions like
($event, ...args) => _ctx.eventHandler($event, ...args)
.Note
This is my first pr to vuejs, and I have limited experience in working with tests. Although the tests are passing, I'm not convinced everything is correct.
When working to resolve this issue, this line was never touched. I can also see that the coverage test doesn't touch it either. I haven't quite understood what it does, but I decided to change it anyway.
Additional note
e2e kept failing when running the tests. Sometimes they passed, other times the failed. I don't know if this is common, or if it's related to my setup somehow. I've managed to at some point get all tests to pass, while running them individually.