Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions packages/compiler-sfc/__tests__/compileScript.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,25 @@ describe('SFC compile <script setup>', () => {
expect(content).toMatch(`"--${mockId}-count": (count.value)`)
assertCode(content)
})

test('the v-for wrapped in parentheses can be correctly parsed & inline is false', () => {
expect(() =>
compile(
`
<script setup lang="ts">
import { ref } from 'vue'
const stacks = ref([])
</script>
<template>
<div v-for="({ file: efile }) of stacks"></div>
</template>
`,
{
inlineTemplate: false
}
)
).not.toThrowError()
})
})

describe('with TypeScript', () => {
Expand Down
4 changes: 3 additions & 1 deletion packages/compiler-sfc/src/script/importUsageCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ function processExp(exp: string, dir?: string): string {
} else if (dir === 'for') {
const inMatch = exp.match(forAliasRE)
if (inMatch) {
const [, LHS, RHS] = inMatch
let [, LHS, RHS] = inMatch
// #6088
LHS = LHS.replace(/\(|\)/g, '')
return processExp(`(${LHS})=>{}`) + processExp(RHS)
}
}
Expand Down