Skip to content

Commit

Permalink
fix(compiler-sfc): fix prefixIdentifier default value
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Aug 15, 2024
1 parent fe00815 commit 3d6f015
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,19 @@ test('namespace / dot component usage', () => {
expect(content).toMatch('return { get Foo() { return Foo } }')
assertCode(content)
})

test('check when has explicit parse options', () => {
const { content } = compile(
`
<script setup lang="ts">
import { x } from './x'
</script>
<template>
{{ x }}
</template>
`,
undefined,
{ templateParseOptions: {} },
)
expect(content).toMatch('return { get x() { return x } }')
})
3 changes: 2 additions & 1 deletion packages/compiler-sfc/src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export function parse(
pad = false,
ignoreEmpty = true,
compiler = CompilerDOM,
templateParseOptions = { prefixIdentifiers: true },
templateParseOptions = {},
} = options

const descriptor: SFCDescriptor = {
Expand All @@ -152,6 +152,7 @@ export function parse(
const errors: (CompilerError | SyntaxError)[] = []
const ast = compiler.parse(source, {
parseMode: 'sfc',
prefixIdentifiers: true,
...templateParseOptions,
onError: e => {
errors.push(e)
Expand Down

0 comments on commit 3d6f015

Please sign in to comment.