]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler-vapor): should not prefix member expression (#92)
authorzhiyuanzmj <32807958+zhiyuanzmj@users.noreply.github.com>
Fri, 12 Jan 2024 19:26:50 +0000 (03:26 +0800)
committerGitHub <noreply@github.com>
Fri, 12 Jan 2024 19:26:50 +0000 (03:26 +0800)
packages/compiler-vapor/__tests__/transforms/__snapshots__/vOn.spec.ts.snap
packages/compiler-vapor/__tests__/transforms/vOn.spec.ts
packages/compiler-vapor/src/generate.ts

index 7aa9e632ac6634e4d0f8b6a74968f8433e5f51cd..a469d61bd47e4796a2dcd7d8068e7e30d3e15afe 100644 (file)
@@ -226,6 +226,18 @@ export function render(_ctx) {
 }"
 `;
 
+exports[`v-on > should not prefix member expression 1`] = `
+"import { template as _template, children as _children, on as _on } from 'vue/vapor';
+
+export function render(_ctx) {
+  const t0 = _template("<div></div>")
+  const n0 = t0()
+  const { 0: [n1],} = _children(n0)
+  _on(n1, "click", (...args) => (_ctx.foo.bar && _ctx.foo.bar(...args)))
+  return n0
+}"
+`;
+
 exports[`v-on > should not wrap keys guard if no key modifier is present 1`] = `
 "import { template as _template, children as _children, on as _on, withModifiers as _withModifiers } from 'vue/vapor';
 
index 0b64270696c5f1664b3c08fbc88a87bdb182095a..6fae1713fe18e35e5b2b5e2666cb71f2c5db504c 100644 (file)
@@ -707,4 +707,15 @@ describe('v-on', () => {
       '(_ctx.event) === "click" ? "mouseup" : (_ctx.event)',
     )
   })
+
+  test('should not prefix member expression', () => {
+    const { code } = compileWithVOn(`<div @click="foo.bar"/>`, {
+      prefixIdentifiers: true,
+    })
+
+    expect(code).matchSnapshot()
+    expect(code).contains(
+      `_on(n1, "click", (...args) => (_ctx.foo.bar && _ctx.foo.bar(...args)))`,
+    )
+  })
 })
index 262ba0898d9ff723fde819db0bf732ab8c0fef13..9d916146fe121ae83e8ff40e9e1112efe380a6bc 100644 (file)
@@ -652,7 +652,7 @@ function genExpression(
       if (isLocal) return
       ids.push(id)
     },
-    true,
+    false,
     [],
     knownIds,
   )