fix(compiler-core/v-on): handle falsy values when caching v-on handlers

fix #2605
This commit is contained in:
Evan You
2020-11-30 16:30:36 -05:00
parent 3cd30c5245
commit e4f09c1419
2 changed files with 43 additions and 3 deletions

View File

@@ -108,9 +108,9 @@ export const transformOn: DirectiveTransform = (
// avoiding the need to be patched.
if (shouldCache && isMemberExp) {
if (exp.type === NodeTypes.SIMPLE_EXPRESSION) {
exp.content += `(...args)`
exp.content = `${exp.content} && ${exp.content}(...args)`
} else {
exp.children.push(`(...args)`)
exp.children = [...exp.children, ` && `, ...exp.children, `(...args)`]
}
}
}