fix(compiler-sfc): fix import usage check for kebab-case same name shorthand binding

fix #11745
close #11754
This commit is contained in:
Evan You 2024-09-02 17:29:40 +08:00
parent d86fe0ec00
commit 0f7c0e5dc0
No known key found for this signature in database
GPG Key ID: 00E9AB7A6704CE0A
2 changed files with 16 additions and 1 deletions

View 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 }')
})

View 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 (