From 760443dca6b132894c58d1144ae99b3fcf1d7957 Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 18 Nov 2020 12:34:59 -0500 Subject: [PATCH] wip: ensure string template refs work in inline mode --- .../compiler-core/src/transforms/transformElement.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/compiler-core/src/transforms/transformElement.ts b/packages/compiler-core/src/transforms/transformElement.ts index f5f026be..e9e1ac58 100644 --- a/packages/compiler-core/src/transforms/transformElement.ts +++ b/packages/compiler-core/src/transforms/transformElement.ts @@ -364,8 +364,15 @@ export function buildProps( const prop = props[i] if (prop.type === NodeTypes.ATTRIBUTE) { const { loc, name, value } = prop + let isStatic = true if (name === 'ref') { hasRef = true + // 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) { + isStatic = false + } } // skip :is on if (name === 'is' && tag === 'component') { @@ -380,7 +387,7 @@ export function buildProps( ), createSimpleExpression( value ? value.content : '', - true, + isStatic, value ? value.loc : loc ) )