Преглед изворни кода

fix(compiler): only generate non-static ref for script setup if the binding exists

fix #4431
Evan You пре 4 година
родитељ
комит
3628991906
1 измењених фајлова са 6 додато и 1 уклоњено
  1. 6 1
      packages/compiler-core/src/transforms/transformElement.ts

+ 6 - 1
packages/compiler-core/src/transforms/transformElement.ts

@@ -465,7 +465,12 @@ export function buildProps(
         // in inline mode there is no setupState object, so we can't use string
         // keys to set the ref. Instead, we need to transform it to pass the
         // acrtual ref instead.
-        if (!__BROWSER__ && context.inline) {
+        if (
+          !__BROWSER__ &&
+          value &&
+          context.inline &&
+          context.bindingMetadata[value.content]
+        ) {
           isStatic = false
         }
       }