Преглед изворни кода

chore: use ast node creation helper (#5255)

阿崔cxr пре 4 година
родитељ
комит
e85e0a7f3a
1 измењених фајлова са 6 додато и 6 уклоњено
  1. 6 6
      packages/compiler-core/src/transforms/transformText.ts

+ 6 - 6
packages/compiler-core/src/transforms/transformText.ts

@@ -5,7 +5,8 @@ import {
   createCallExpression,
   CallExpression,
   ElementTypes,
-  ConstantTypes
+  ConstantTypes,
+  createCompoundExpression
 } from '../ast'
 import { isText } from '../utils'
 import { CREATE_TEXT } from '../runtimeHelpers'
@@ -36,11 +37,10 @@ export const transformText: NodeTransform = (node, context) => {
             const next = children[j]
             if (isText(next)) {
               if (!currentContainer) {
-                currentContainer = children[i] = {
-                  type: NodeTypes.COMPOUND_EXPRESSION,
-                  loc: child.loc,
-                  children: [child]
-                }
+                currentContainer = children[i] = createCompoundExpression(
+                  [child],
+                  child.loc
+                )
               }
               // merge adjacent text node into current
               currentContainer.children.push(` + `, next)