chore: use ast node creation helper (#5255)
This commit is contained in:
parent
9def7aa508
commit
e85e0a7f3a
@ -5,7 +5,8 @@ import {
|
|||||||
createCallExpression,
|
createCallExpression,
|
||||||
CallExpression,
|
CallExpression,
|
||||||
ElementTypes,
|
ElementTypes,
|
||||||
ConstantTypes
|
ConstantTypes,
|
||||||
|
createCompoundExpression
|
||||||
} from '../ast'
|
} from '../ast'
|
||||||
import { isText } from '../utils'
|
import { isText } from '../utils'
|
||||||
import { CREATE_TEXT } from '../runtimeHelpers'
|
import { CREATE_TEXT } from '../runtimeHelpers'
|
||||||
@ -36,11 +37,10 @@ export const transformText: NodeTransform = (node, context) => {
|
|||||||
const next = children[j]
|
const next = children[j]
|
||||||
if (isText(next)) {
|
if (isText(next)) {
|
||||||
if (!currentContainer) {
|
if (!currentContainer) {
|
||||||
currentContainer = children[i] = {
|
currentContainer = children[i] = createCompoundExpression(
|
||||||
type: NodeTypes.COMPOUND_EXPRESSION,
|
[child],
|
||||||
loc: child.loc,
|
child.loc
|
||||||
children: [child]
|
)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// merge adjacent text node into current
|
// merge adjacent text node into current
|
||||||
currentContainer.children.push(` + `, next)
|
currentContainer.children.push(` + `, next)
|
||||||
|
Loading…
Reference in New Issue
Block a user