From d1dd1e110a1efcb6ed13ba8db024c1c0d588b9b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Sun, 10 Dec 2023 01:36:34 +0800 Subject: [PATCH] fix(compiler-vapor): add modifier for empty v-on --- packages/compiler-vapor/src/generate.ts | 48 ++++++++++++------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/packages/compiler-vapor/src/generate.ts b/packages/compiler-vapor/src/generate.ts index ba2a3aeb5..b79ac2901 100644 --- a/packages/compiler-vapor/src/generate.ts +++ b/packages/compiler-vapor/src/generate.ts @@ -494,31 +494,31 @@ function genSetEvent(oper: SetEventIRNode, context: CodegenContext) { }, // 3rd arg: event handler () => { - if (oper.value && oper.value.content.trim()) { - const pushWithKeys = (fn: () => void) => { - push(`${vaporHelper('withKeys')}(`) - fn() - push(`, ${genArrayExpression(keys)})`) - } - const pushWithModifiers = (fn: () => void) => { - push(`${vaporHelper('withModifiers')}(`) - fn() - push(`, ${genArrayExpression(nonKeys)})`) - } - const pushNoop = (fn: () => void) => fn() - - ;(keys.length ? pushWithKeys : pushNoop)(() => - (nonKeys.length ? pushWithModifiers : pushNoop)(() => { - push('(...args) => (') - genExpression(oper.value!, context) - push(' && ') - genExpression(oper.value!, context) - push('(...args))') - }), - ) - } else { - push('() => {}') + const pushWithKeys = (fn: () => void) => { + push(`${vaporHelper('withKeys')}(`) + fn() + push(`, ${genArrayExpression(keys)})`) } + const pushWithModifiers = (fn: () => void) => { + push(`${vaporHelper('withModifiers')}(`) + fn() + push(`, ${genArrayExpression(nonKeys)})`) + } + const pushNoop = (fn: () => void) => fn() + + ;(keys.length ? pushWithKeys : pushNoop)(() => + (nonKeys.length ? pushWithModifiers : pushNoop)(() => { + if (oper.value && oper.value.content.trim()) { + push('(...args) => (') + genExpression(oper.value, context) + push(' && ') + genExpression(oper.value, context) + push('(...args))') + } else { + push('() => {}') + } + }), + ) }, // 4th arg, gen options !!options.length &&