From: Evan You Date: Tue, 10 Nov 2020 22:31:09 +0000 (-0500) Subject: wip: fix binding type fallback X-Git-Tag: v3.0.3~50^2~17 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3019508e75334e4f1a37951201464d50b89b1ca3;p=thirdparty%2Fvuejs%2Fcore.git wip: fix binding type fallback --- diff --git a/packages/compiler-core/src/codegen.ts b/packages/compiler-core/src/codegen.ts index 0ab78993d4..299106fde3 100644 --- a/packages/compiler-core/src/codegen.ts +++ b/packages/compiler-core/src/codegen.ts @@ -227,7 +227,7 @@ export function generate( if (genScopeId) { push(`${PURE_ANNOTATION}_withId(`) } - push(`() => {`) + push(`(_ctx, _cache${optimizeSources}) => {`) } else { if (genScopeId) { push(`const render = ${PURE_ANNOTATION}_withId(`) diff --git a/packages/compiler-core/src/transforms/transformExpression.ts b/packages/compiler-core/src/transforms/transformExpression.ts index 0f10d88fe0..7552177c6a 100644 --- a/packages/compiler-core/src/transforms/transformExpression.ts +++ b/packages/compiler-core/src/transforms/transformExpression.ts @@ -100,19 +100,17 @@ export function processExpression( const { inline, inlinePropsIdentifier, bindingMetadata } = context const prefix = (raw: string) => { + const type = hasOwn(bindingMetadata, raw) && bindingMetadata[raw] if (inline) { - // setup inline mode, it's either props or setup - if (bindingMetadata[raw] !== 'setup') { + // setup inline mode + if (type === 'props') { return `${inlinePropsIdentifier}.${raw}` - } else { + } else if (type === 'setup') { return `${context.helperString(UNREF)}(${raw})` } - } else { - const source = hasOwn(bindingMetadata, raw) - ? `$` + bindingMetadata[raw] - : `_ctx` - return `${source}.${raw}` } + // fallback to normal + return `${type ? `$${type}` : `_ctx`}.${raw}` } // fast path if expression is a simple identifier. diff --git a/packages/compiler-sfc/src/compileScript.ts b/packages/compiler-sfc/src/compileScript.ts index 94eb0e56f8..ab5aa43ae5 100644 --- a/packages/compiler-sfc/src/compileScript.ts +++ b/packages/compiler-sfc/src/compileScript.ts @@ -685,6 +685,7 @@ export function compileScript( if (script) { if (startOffset < scriptStartOffset!) { //