From: 三咲智子 Kevin Deng Date: Sat, 9 Dec 2023 17:36:34 +0000 (+0800) Subject: fix(compiler-vapor): add modifier for empty v-on X-Git-Tag: v3.6.0-alpha.1~16^2~717 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d1dd1e110a1efcb6ed13ba8db024c1c0d588b9b8;p=thirdparty%2Fvuejs%2Fcore.git fix(compiler-vapor): add modifier for empty v-on --- diff --git a/packages/compiler-vapor/src/generate.ts b/packages/compiler-vapor/src/generate.ts index ba2a3aeb57..b79ac29019 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() + 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)(() => { + ;(keys.length ? pushWithKeys : pushNoop)(() => + (nonKeys.length ? pushWithModifiers : pushNoop)(() => { + if (oper.value && oper.value.content.trim()) { push('(...args) => (') - genExpression(oper.value!, context) + genExpression(oper.value, context) push(' && ') - genExpression(oper.value!, context) + genExpression(oper.value, context) push('(...args))') - }), - ) - } else { - push('() => {}') - } + } else { + push('() => {}') + } + }), + ) }, // 4th arg, gen options !!options.length &&