fix(compiler-vapor): add modifier for empty v-on

This commit is contained in:
三咲智子 Kevin Deng 2023-12-10 01:36:34 +08:00
parent b421aa91a2
commit d1dd1e110a
No known key found for this signature in database
GPG Key ID: 69992F2250DFD93E
1 changed files with 24 additions and 24 deletions

View File

@ -494,7 +494,6 @@ function genSetEvent(oper: SetEventIRNode, context: CodegenContext) {
}, },
// 3rd arg: event handler // 3rd arg: event handler
() => { () => {
if (oper.value && oper.value.content.trim()) {
const pushWithKeys = (fn: () => void) => { const pushWithKeys = (fn: () => void) => {
push(`${vaporHelper('withKeys')}(`) push(`${vaporHelper('withKeys')}(`)
fn() fn()
@ -509,16 +508,17 @@ function genSetEvent(oper: SetEventIRNode, context: CodegenContext) {
;(keys.length ? pushWithKeys : pushNoop)(() => ;(keys.length ? pushWithKeys : pushNoop)(() =>
(nonKeys.length ? pushWithModifiers : pushNoop)(() => { (nonKeys.length ? pushWithModifiers : pushNoop)(() => {
if (oper.value && oper.value.content.trim()) {
push('(...args) => (') push('(...args) => (')
genExpression(oper.value!, context) genExpression(oper.value, context)
push(' && ') push(' && ')
genExpression(oper.value!, context) genExpression(oper.value, context)
push('(...args))') push('(...args))')
}),
)
} else { } else {
push('() => {}') push('() => {}')
} }
}),
)
}, },
// 4th arg, gen options // 4th arg, gen options
!!options.length && !!options.length &&