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

Function normalizeArrayChildren

static/vuejs/vue.runtime.js:1769–1799  ·  view source on GitHub ↗
(children, nestedIndex)

Source from the content-addressed store, hash-verified

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

Callers 1

normalizeChildrenFunction · 0.70

Calls 2

isPrimitiveFunction · 0.70
createTextVNodeFunction · 0.70

Tested by

no test coverage detected