白雾三语
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
22 additions and
1 deletions
-
packages/compiler-sfc/__tests__/compileScript.spec.ts
-
packages/compiler-sfc/src/script/importUsageCheck.ts
|
|
@ -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', () => { |
|
|
|
|
|
@ -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.trim().replace(/^\(|\)$/g, '') |
|
|
|
return processExp(`(${LHS})=>{}`) + processExp(RHS) |
|
|
|
} |
|
|
|
} |
|
|
|