fix(compiler-core/v-on): pass noninitial arguments in cached event handlers (#1265)

This commit is contained in:
Cathrine Vaage
2020-06-15 21:04:03 +02:00
committed by GitHub
parent 35dbef268c
commit 7e28173312
3 changed files with 18 additions and 10 deletions

View File

@@ -83,9 +83,9 @@ export const transformOn: DirectiveTransform = (
// avoiding the need to be patched.
if (isCacheable && isMemberExp) {
if (exp.type === NodeTypes.SIMPLE_EXPRESSION) {
exp.content += `($event)`
exp.content += `($event, ...args)`
} else {
exp.children.push(`($event)`)
exp.children.push(`($event, ...args)`)
}
}
}
@@ -102,7 +102,7 @@ export const transformOn: DirectiveTransform = (
if (isInlineStatement || (isCacheable && isMemberExp)) {
// wrap inline statement in a function expression
exp = createCompoundExpression([
`$event => ${hasMultipleStatements ? `{` : `(`}`,
`($event, ...args) => ${hasMultipleStatements ? `{` : `(`}`,
exp,
hasMultipleStatements ? `}` : `)`
])