Skip to content

Commit

Permalink
fix(compiler-sfc): fix template usage check edge case for v-on statem…
Browse files Browse the repository at this point in the history
…ents

ref: vuejs/vue#12591
  • Loading branch information
yyx990803 committed Jul 4, 2022
1 parent fb3bfde commit 769e555
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/compiler-sfc/__tests__/compileScript.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,19 @@ defineExpose({ foo: 123 })
expect(content).toMatch(`return { a, b, Baz }`)
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>

This comment has been minimized.

Copy link
@Gnapstar

Gnapstar Jul 5, 2022

👀

`)
})
})

describe('inlineTemplate mode', () => {
Expand Down
2 changes: 2 additions & 0 deletions packages/compiler-sfc/src/compileScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2134,6 +2134,8 @@ function processExp(exp: string, dir?: string): string {
if (/ as\s+\w|<.*>|:/.test(exp)) {
if (dir === 'slot') {
exp = `(${exp})=>{}`
} else if (dir === 'on') {
exp = `()=>{${exp}}`
} else if (dir === 'for') {
const inMatch = exp.match(forAliasRE)
if (inMatch) {
Expand Down

0 comments on commit 769e555

Please sign in to comment.