fix(compiler-sfc): fix template usage check edge case for v-on statements
ref: https://github.com/vuejs/vue/issues/12591
This commit is contained in:
parent
fb3bfde264
commit
769e5555f9
@ -461,6 +461,19 @@ defineExpose({ foo: 123 })
|
|||||||
expect(content).toMatch(`return { a, b, Baz }`)
|
expect(content).toMatch(`return { a, b, Baz }`)
|
||||||
assertCode(content)
|
assertCode(content)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// vuejs/vue#12591
|
||||||
|
test('v-on inline statement', () => {
|
||||||
|
// should not error
|
||||||
|
compile(`
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { foo } from './foo'
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<div @click="$emit('update:a');"></div>
|
||||||
|
</tempalte>
|
||||||
|
`)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('inlineTemplate mode', () => {
|
describe('inlineTemplate mode', () => {
|
||||||
|
@ -2134,6 +2134,8 @@ function processExp(exp: string, dir?: string): string {
|
|||||||
if (/ as\s+\w|<.*>|:/.test(exp)) {
|
if (/ as\s+\w|<.*>|:/.test(exp)) {
|
||||||
if (dir === 'slot') {
|
if (dir === 'slot') {
|
||||||
exp = `(${exp})=>{}`
|
exp = `(${exp})=>{}`
|
||||||
|
} else if (dir === 'on') {
|
||||||
|
exp = `()=>{${exp}}`
|
||||||
} else if (dir === 'for') {
|
} else if (dir === 'for') {
|
||||||
const inMatch = exp.match(forAliasRE)
|
const inMatch = exp.match(forAliasRE)
|
||||||
if (inMatch) {
|
if (inMatch) {
|
||||||
|
Loading…
Reference in New Issue
Block a user