fix(compiler-vapor): generate static expression

This commit is contained in:
三咲智子 Kevin Deng 2023-12-09 23:29:10 +08:00
parent 341ddf0190
commit 45e86e36d7
No known key found for this signature in database
GPG Key ID: 69992F2250DFD93E
1 changed files with 3 additions and 6 deletions

View File

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