Skip to content

Commit ec70b44

Browse files
committed
tweak noramlizeArrayChildren
1 parent f2bd882 commit ec70b44

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/core/vdom/helpers/normalize-children.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ export function normalizeChildren (children: any): ?Array<VNode> {
3636
: undefined
3737
}
3838

39+
function isTextNode (node): boolean {
40+
return isDef(node) && isDef(node.text) && isFalse(node.isComment)
41+
}
42+
3943
function normalizeArrayChildren (children: any, nestedIndex?: string): Array<VNode> {
4044
const res = []
4145
let i, c, last
@@ -47,14 +51,14 @@ function normalizeArrayChildren (children: any, nestedIndex?: string): Array<VNo
4751
if (Array.isArray(c)) {
4852
res.push.apply(res, normalizeArrayChildren(c, `${nestedIndex || ''}_${i}`))
4953
} else if (isPrimitive(c)) {
50-
if (isDef(last) && isDef(last.text)) {
51-
last.text += String(c)
54+
if (isTextNode(last)) {
55+
(last: any).text += String(c)
5256
} else if (c !== '') {
5357
// convert primitive to vnode
5458
res.push(createTextVNode(c))
5559
}
5660
} else {
57-
if (isFalse(c.isComment) && isDef(c.text) && isDef(last) && isFalse(last.isComment) && isDef(last.text)) {
61+
if (isTextNode(c) && isTextNode(last)) {
5862
res[res.length - 1] = createTextVNode(last.text + c.text)
5963
} else {
6064
// default key for nested array children (likely generated by v-for)

0 commit comments

Comments
 (0)