MCPcopy
hub / github.com/fanmingming/live / normalizeArrayChildren

Function normalizeArrayChildren

m3u8/vue.js:2375–2421  ·  view source on GitHub ↗
(children, nestedIndex)

Source from the content-addressed store, hash-verified

2373 }
2374
2375 function normalizeArrayChildren (children, nestedIndex) {
2376 var res = [];
2377 var i, c, lastIndex, last;
2378 for (i = 0; i < children.length; i++) {
2379 c = children[i];
2380 if (isUndef(c) || typeof c === 'boolean') { continue }
2381 lastIndex = res.length - 1;
2382 last = res[lastIndex];
2383 // nested
2384 if (Array.isArray(c)) {
2385 if (c.length > 0) {
2386 c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i));
2387 // merge adjacent text nodes
2388 if (isTextNode(c[0]) && isTextNode(last)) {
2389 res[lastIndex] = createTextVNode(last.text + (c[0]).text);
2390 c.shift();
2391 }
2392 res.push.apply(res, c);
2393 }
2394 } else if (isPrimitive(c)) {
2395 if (isTextNode(last)) {
2396 // merge adjacent text nodes
2397 // this is necessary for SSR hydration because text nodes are
2398 // essentially merged when rendered to HTML strings
2399 res[lastIndex] = createTextVNode(last.text + c);
2400 } else if (c !== '') {
2401 // convert primitive to vnode
2402 res.push(createTextVNode(c));
2403 }
2404 } else {
2405 if (isTextNode(c) && isTextNode(last)) {
2406 // merge adjacent text nodes
2407 res[lastIndex] = createTextVNode(last.text + c.text);
2408 } else {
2409 // default key for nested array children (likely generated by v-for)
2410 if (isTrue(children._isVList) &&
2411 isDef(c.tag) &&
2412 isUndef(c.key) &&
2413 isDef(nestedIndex)) {
2414 c.key = "__vlist" + nestedIndex + "_" + i + "__";
2415 }
2416 res.push(c);
2417 }
2418 }
2419 }
2420 return res
2421 }
2422
2423 /* */
2424

Callers 1

normalizeChildrenFunction · 0.85

Calls 6

isUndefFunction · 0.85
isTextNodeFunction · 0.85
createTextVNodeFunction · 0.85
isPrimitiveFunction · 0.85
isTrueFunction · 0.85
isDefFunction · 0.85

Tested by

no test coverage detected