]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler-vapor): add modifier for empty v-on
author三咲智子 Kevin Deng <sxzz@sxzz.moe>
Sat, 9 Dec 2023 17:36:34 +0000 (01:36 +0800)
committer三咲智子 Kevin Deng <sxzz@sxzz.moe>
Sat, 9 Dec 2023 17:36:34 +0000 (01:36 +0800)
packages/compiler-vapor/src/generate.ts

index ba2a3aeb57b076b0c1a07dc42044154b1ff1e073..b79ac2901925817bf2e978e81ff08edcde142c80 100644 (file)
@@ -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 &&