From 8f2e32cb9b43b0b8e949e455ac78b634d119a3c9 Mon Sep 17 00:00:00 2001 From: Evan You Date: Sat, 28 Oct 2023 16:17:50 +0900 Subject: [PATCH] refactor: move condition up --- .../src/transforms/transformExpression.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/compiler-core/src/transforms/transformExpression.ts b/packages/compiler-core/src/transforms/transformExpression.ts index 5a8483dedf0..52d1fb42a13 100644 --- a/packages/compiler-core/src/transforms/transformExpression.ts +++ b/packages/compiler-core/src/transforms/transformExpression.ts @@ -227,18 +227,20 @@ export function processExpression( const isScopeVarReference = context.identifiers[rawExp] const isAllowedGlobal = isGloballyAllowed(rawExp) const isLiteral = isLiteralWhitelisted(rawExp) - if (!asParams && !isScopeVarReference && !isAllowedGlobal && !isLiteral) { + if ( + !asParams && + !isScopeVarReference && + !isLiteral && + (!isAllowedGlobal || bindingMetadata[rawExp]) + ) { // const bindings exposed from setup can be skipped for patching but // cannot be hoisted to module scope - if (isConst(bindingMetadata[node.content])) { + if (isConst(bindingMetadata[rawExp])) { node.constType = ConstantTypes.CAN_SKIP_PATCH } node.content = rewriteIdentifier(rawExp) } else if (!isScopeVarReference) { - if (isAllowedGlobal && bindingMetadata[rawExp]) { - // #9482 - node.content = rewriteIdentifier(rawExp) - } else if (isLiteral) { + if (isLiteral) { node.constType = ConstantTypes.CAN_STRINGIFY } else { node.constType = ConstantTypes.CAN_HOIST