]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler-sfc): fix import usage check for kebab-case same name shorthand binding
authorEvan You <evan@vuejs.org>
Mon, 2 Sep 2024 09:29:40 +0000 (17:29 +0800)
committerEvan You <evan@vuejs.org>
Mon, 2 Sep 2024 09:29:59 +0000 (17:29 +0800)
fix #11745
close #11754

packages/compiler-sfc/__tests__/compileScript/importUsageCheck.spec.ts
packages/compiler-sfc/src/script/importUsageCheck.ts

index fe52b12d4e51514b3d66470ea142a10ce57dd0aa..210fa09688a4175a66278eedcd19a026d56c2a3d 100644 (file)
@@ -250,3 +250,18 @@ test('check when has explicit parse options', () => {
   )
   expect(content).toMatch('return { get x() { return x } }')
 })
+
+// #11745
+test('shorthand binding w/ kebab-case', () => {
+  const { content } = compile(
+    `
+    <script setup lang="ts">
+      import { fooBar } from "./foo.ts"
+    </script>
+    <template>
+      <div :foo-bar></div>
+    </template>
+    `,
+  )
+  expect(content).toMatch('return { get fooBar() { return fooBar }')
+})
index 6b9fbc634ccb29f41369896211fccc016ab075e3..22ef37cf37f5ab98ab4081a4a893f74cf6fc599f 100644 (file)
@@ -62,7 +62,7 @@ function resolveTemplateUsedIdentifiers(sfc: SFCDescriptor): Set<string> {
               extractIdentifiers(ids, prop.exp)
             } else if (prop.name === 'bind' && !prop.exp) {
               // v-bind shorthand name as identifier
-              ids.add((prop.arg as SimpleExpressionNode).content)
+              ids.add(camelize((prop.arg as SimpleExpressionNode).content))
             }
           }
           if (