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

Function normalizeArrayChildren

static/vuejs/vue.esm.js:1767–1797  ·  view source on GitHub ↗
(children, nestedIndex)

Source from the content-addressed store, hash-verified

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

Callers 1

normalizeChildrenFunction · 0.70

Calls 2

isPrimitiveFunction · 0.70
createTextVNodeFunction · 0.70

Tested by

no test coverage detected