From 69d5c6887e51687044da25ef671c690d193000d7 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 24 Nov 2020 19:04:03 -0500 Subject: [PATCH] wip: update directive scope variable mapping --- .../src/transforms/transformElement.ts | 31 ++++++------------- .../__snapshots__/compileScript.spec.ts.snap | 4 +-- .../__tests__/compileScript.spec.ts | 4 +-- 3 files changed, 14 insertions(+), 25 deletions(-) diff --git a/packages/compiler-core/src/transforms/transformElement.ts b/packages/compiler-core/src/transforms/transformElement.ts index c9d1a3ee4..ca1ae9d1b 100644 --- a/packages/compiler-core/src/transforms/transformElement.ts +++ b/packages/compiler-core/src/transforms/transformElement.ts @@ -257,11 +257,7 @@ export function resolveComponentType( // this is skipped in browser build since browser builds do not perform // binding analysis. if (!__BROWSER__) { - const fromSetup = resolveSetupReference( - tag, - capitalize(camelize(tag)), - context - ) + const fromSetup = resolveSetupReference(tag, context) if (fromSetup) { return fromSetup } @@ -273,22 +269,23 @@ export function resolveComponentType( return toValidAssetId(tag, `component`) } -function resolveSetupReference( - name: string, - interopName: string, - context: TransformContext -) { +function resolveSetupReference(name: string, context: TransformContext) { const bindings = context.bindingMetadata if (!bindings) { return } + const camelName = camelize(name) + const PascalName = capitalize(camelName) const checkType = (type: BindingTypes) => { if (bindings[name] === type) { return name } - if (bindings[interopName] === type) { - return interopName + if (bindings[camelName] === type) { + return camelName + } + if (bindings[PascalName] === type) { + return PascalName } } @@ -615,15 +612,7 @@ function buildDirectiveArgs( } else { // user directive. // see if we have directives exposed via