]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip: fix binding type fallback
authorEvan You <yyx990803@gmail.com>
Tue, 10 Nov 2020 22:31:09 +0000 (17:31 -0500)
committerEvan You <yyx990803@gmail.com>
Tue, 10 Nov 2020 22:31:09 +0000 (17:31 -0500)
packages/compiler-core/src/codegen.ts
packages/compiler-core/src/transforms/transformExpression.ts
packages/compiler-sfc/src/compileScript.ts

index 0ab78993d415a4594a5d5bf69f3b3222b0908167..299106fde3b986c08cc33a4ad83fa1f56d44a470 100644 (file)
@@ -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(`)
index 0f10d88fe023c11bb9a84672eec927567ae67f05..7552177c6aa361c49ac3a0a056c79964db387605 100644 (file)
@@ -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.
index 94eb0e56f8deaea5754ab41150dfd5f4ac6acb0e..ab5aa43ae55a3b4092e87570c12b4f659a7a746c 100644 (file)
@@ -685,6 +685,7 @@ export function compileScript(
   if (script) {
     if (startOffset < scriptStartOffset!) {
       // <script setup> before <script>
+      s.remove(0, startOffset)
       s.remove(endOffset, scriptStartOffset!)
       s.remove(scriptEndOffset!, source.length)
     } else {