]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler-sfc): fix prefixIdentifier default value
authorEvan You <evan@vuejs.org>
Thu, 15 Aug 2024 06:29:14 +0000 (14:29 +0800)
committerEvan You <evan@vuejs.org>
Thu, 15 Aug 2024 06:29:28 +0000 (14:29 +0800)
packages/compiler-sfc/__tests__/compileScript/importUsageCheck.spec.ts
packages/compiler-sfc/src/parse.ts

index b842f7a466dee7c0d5a2962139b5436c0df4f856..fe52b12d4e51514b3d66470ea142a10ce57dd0aa 100644 (file)
@@ -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 } }')
+})
index 08d86244685254c500a9f5e5d3434bf8f5ea1951..01a4bec6eeb3b40da16f04e65bec2c95f76b07fe 100644 (file)
@@ -133,7 +133,7 @@ export function parse(
     pad = false,
     ignoreEmpty = true,
     compiler = CompilerDOM,
-    templateParseOptions = { prefixIdentifiers: true },
+    templateParseOptions = {},
   } = options
 
   const descriptor: SFCDescriptor = {
@@ -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)