Skip to content

Commit

Permalink
fix(compiler-sfc): fix import usage check for kebab-case same name sh…
Browse files Browse the repository at this point in the history
…orthand binding

fix #11745
close #11754
  • Loading branch information
yyx990803 committed Sep 2, 2024
1 parent d86fe0e commit 0f7c0e5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 }')
})
2 changes: 1 addition & 1 deletion packages/compiler-sfc/src/script/importUsageCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit 0f7c0e5

Please sign in to comment.