|
|
@ -5,7 +5,8 @@ import VNode from './vnode' |
|
|
|
|
|
|
|
export function normalizeChildren ( |
|
|
|
children: any, |
|
|
|
ns: string | void |
|
|
|
ns: string | void, |
|
|
|
nestedIndex: number | void |
|
|
|
): Array<VNode> | void { |
|
|
|
if (isPrimitive(children)) { |
|
|
|
return [createTextVNode(children)] |
|
|
@ -17,7 +18,7 @@ export function normalizeChildren ( |
|
|
|
const last = res[res.length - 1] |
|
|
|
// nested
|
|
|
|
if (Array.isArray(c)) { |
|
|
|
res.push.apply(res, normalizeChildren(c, ns)) |
|
|
|
res.push.apply(res, normalizeChildren(c, ns, i)) |
|
|
|
} else if (isPrimitive(c)) { |
|
|
|
if (last && last.text) { |
|
|
|
last.text += String(c) |
|
|
@ -33,6 +34,10 @@ export function normalizeChildren ( |
|
|
|
if (ns) { |
|
|
|
applyNS(c, ns) |
|
|
|
} |
|
|
|
// default key for nested array children (likely generated by v-for)
|
|
|
|
if (c.key == null && nestedIndex != null) { |
|
|
|
c.key = `__vlist_${nestedIndex}_${i}__` |
|
|
|
} |
|
|
|
res.push(c) |
|
|
|
} |
|
|
|
} |
|
|
|