瀏覽代碼

fix(compiler-vapor): generate static expression

三咲智子 Kevin Deng 2 年之前
父節點
當前提交
45e86e36d7
共有 1 個文件被更改,包括 3 次插入6 次删除
  1. 3 6
      packages/compiler-vapor/src/generate.ts

+ 3 - 6
packages/compiler-vapor/src/generate.ts

@@ -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