Skip to content

Commit 0f7c0e5

Browse files
committed
fix(compiler-sfc): fix import usage check for kebab-case same name shorthand binding
fix #11745 close #11754
1 parent d86fe0e commit 0f7c0e5

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Diff for: packages/compiler-sfc/__tests__/compileScript/importUsageCheck.spec.ts

+15
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,18 @@ test('check when has explicit parse options', () => {
250250
)
251251
expect(content).toMatch('return { get x() { return x } }')
252252
})
253+
254+
// #11745
255+
test('shorthand binding w/ kebab-case', () => {
256+
const { content } = compile(
257+
`
258+
<script setup lang="ts">
259+
import { fooBar } from "./foo.ts"
260+
</script>
261+
<template>
262+
<div :foo-bar></div>
263+
</template>
264+
`,
265+
)
266+
expect(content).toMatch('return { get fooBar() { return fooBar }')
267+
})

Diff for: packages/compiler-sfc/src/script/importUsageCheck.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function resolveTemplateUsedIdentifiers(sfc: SFCDescriptor): Set<string> {
6262
extractIdentifiers(ids, prop.exp)
6363
} else if (prop.name === 'bind' && !prop.exp) {
6464
// v-bind shorthand name as identifier
65-
ids.add((prop.arg as SimpleExpressionNode).content)
65+
ids.add(camelize((prop.arg as SimpleExpressionNode).content))
6666
}
6767
}
6868
if (

0 commit comments

Comments
 (0)