mirror of https://github.com/vuejs/vue.git
tweak noramlizeArrayChildren
This commit is contained in:
parent
f2bd882073
commit
ec70b44c28
|
|
@ -36,6 +36,10 @@ export function normalizeChildren (children: any): ?Array<VNode> {
|
|||
: undefined
|
||||
}
|
||||
|
||||
function isTextNode (node): boolean {
|
||||
return isDef(node) && isDef(node.text) && isFalse(node.isComment)
|
||||
}
|
||||
|
||||
function normalizeArrayChildren (children: any, nestedIndex?: string): Array<VNode> {
|
||||
const res = []
|
||||
let i, c, last
|
||||
|
|
@ -47,14 +51,14 @@ function normalizeArrayChildren (children: any, nestedIndex?: string): Array<VNo
|
|||
if (Array.isArray(c)) {
|
||||
res.push.apply(res, normalizeArrayChildren(c, `${nestedIndex || ''}_${i}`))
|
||||
} else if (isPrimitive(c)) {
|
||||
if (isDef(last) && isDef(last.text)) {
|
||||
last.text += String(c)
|
||||
if (isTextNode(last)) {
|
||||
(last: any).text += String(c)
|
||||
} else if (c !== '') {
|
||||
// convert primitive to vnode
|
||||
res.push(createTextVNode(c))
|
||||
}
|
||||
} else {
|
||||
if (isFalse(c.isComment) && isDef(c.text) && isDef(last) && isFalse(last.isComment) && isDef(last.text)) {
|
||||
if (isTextNode(c) && isTextNode(last)) {
|
||||
res[res.length - 1] = createTextVNode(last.text + c.text)
|
||||
} else {
|
||||
// default key for nested array children (likely generated by v-for)
|
||||
|
|
|
|||
Loading…
Reference in New Issue