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

Function normalizeArrayChildren

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

Source from the content-addressed store, hash-verified

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

Callers 1

normalizeChildrenFunction · 0.70

Calls 2

isPrimitiveFunction · 0.70
createTextVNodeFunction · 0.70

Tested by

no test coverage detected