fix(compiler-vapor): should not prefix member expression (#92)

This commit is contained in:
zhiyuanzmj 2024-01-13 03:26:50 +08:00 committed by GitHub
parent 2cce436aaf
commit 8d7d672bc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 1 deletions

View 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';

View 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)))`,
)
})
})

View File

@ -652,7 +652,7 @@ function genExpression(
if (isLocal) return
ids.push(id)
},
true,
false,
[],
knownIds,
)