MCPcopy Create free account
hub / github.com/TruthHun/BookStack / normalizeArrayChildren

Function normalizeArrayChildren

static/vuejs/vue.js:1773–1803  ·  view source on GitHub ↗
(children, nestedIndex)

Source from the content-addressed store, hash-verified

1771}
1772
1773function normalizeArrayChildren (children, nestedIndex) {
1774 var res = [];
1775 var i, c, last;
1776 for (i = 0; i < children.length; i++) {
1777 c = children[i];
1778 if (c == null || typeof c === 'boolean') { continue }
1779 last = res[res.length - 1];
1780 // nested
1781 if (Array.isArray(c)) {
1782 res.push.apply(res, normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i)));
1783 } else if (isPrimitive(c)) {
1784 if (last && last.text) {
1785 last.text += String(c);
1786 } else if (c !== '') {
1787 // convert primitive to vnode
1788 res.push(createTextVNode(c));
1789 }
1790 } else {
1791 if (c.text && last && last.text) {
1792 res[res.length - 1] = createTextVNode(last.text + c.text);
1793 } else {
1794 // default key for nested array children (likely generated by v-for)
1795 if (c.tag && c.key == null && nestedIndex != null) {
1796 c.key = "__vlist" + nestedIndex + "_" + i + "__";
1797 }
1798 res.push(c);
1799 }
1800 }
1801 }
1802 return res
1803}
1804
1805/* */
1806

Callers 1

normalizeChildrenFunction · 0.70

Calls 2

isPrimitiveFunction · 0.70
createTextVNodeFunction · 0.70

Tested by

no test coverage detected