diff --git a/packages/compiler-sfc/__tests__/compileScript/importUsageCheck.spec.ts b/packages/compiler-sfc/__tests__/compileScript/importUsageCheck.spec.ts index fe52b12d4e5..210fa09688a 100644 --- a/packages/compiler-sfc/__tests__/compileScript/importUsageCheck.spec.ts +++ b/packages/compiler-sfc/__tests__/compileScript/importUsageCheck.spec.ts @@ -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( + ` + + + `, + ) + expect(content).toMatch('return { get fooBar() { return fooBar }') +}) diff --git a/packages/compiler-sfc/src/script/importUsageCheck.ts b/packages/compiler-sfc/src/script/importUsageCheck.ts index 6b9fbc634cc..22ef37cf37f 100644 --- a/packages/compiler-sfc/src/script/importUsageCheck.ts +++ b/packages/compiler-sfc/src/script/importUsageCheck.ts @@ -62,7 +62,7 @@ function resolveTemplateUsedIdentifiers(sfc: SFCDescriptor): Set { 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 (