]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler-vapor): generate static expression
author三咲智子 Kevin Deng <sxzz@sxzz.moe>
Sat, 9 Dec 2023 15:29:10 +0000 (23:29 +0800)
committer三咲智子 Kevin Deng <sxzz@sxzz.moe>
Sat, 9 Dec 2023 15:29:30 +0000 (23:29 +0800)
packages/compiler-vapor/src/generate.ts

index b7ac40de7ff32a2b98f533e8b180286b5630cd7d..0a71f074db7c7319e219c28a9c3b8ed9a1cb7783 100644 (file)
@@ -525,11 +525,11 @@ function genExpression(node: IRExpression, context: CodegenContext): void {
   if (isString(node)) return push(node)
 
   const { content: rawExpr, ast, isStatic, loc } = node
-  if (__BROWSER__) {
-    return push(rawExpr)
+  if (isStatic) {
+    return push(JSON.stringify(rawExpr), NewlineType.None, loc)
   }
-
   if (
+    __BROWSER__ ||
     !context.prefixIdentifiers ||
     !node.content.trim() ||
     // there was a parsing error
@@ -539,9 +539,6 @@ function genExpression(node: IRExpression, context: CodegenContext): void {
   ) {
     return push(rawExpr, NewlineType.None, loc)
   }
-  if (isStatic) {
-    return push(JSON.stringify(rawExpr), NewlineType.None, loc)
-  }
 
   if (ast === null) {
     // the expression is a simple identifier