* Runtime helper for resolving raw children VNodes into a slot object.
(children, context)
| 2470 | * Runtime helper for resolving raw children VNodes into a slot object. |
| 2471 | */ |
| 2472 | function resolveSlots(children, context) { |
| 2473 | var slots = {}; |
| 2474 | if (!children) { |
| 2475 | return slots; |
| 2476 | } |
| 2477 | for (var i = 0, l = children.length; i < l; i++) { |
| 2478 | var child = children[i]; |
| 2479 | var data = child.data; |
| 2480 | // remove slot attribute if the node is resolved as a Vue slot node |
| 2481 | if (data && data.attrs && data.attrs.slot) { |
| 2482 | delete data.attrs.slot; |
| 2483 | } |
| 2484 | // named slots should only be respected if the vnode was rendered in the |
| 2485 | // same context. |
| 2486 | if ((child.context === context || child.fnContext === context) && data && data.slot != null) { |
| 2487 | var name = data.slot; |
| 2488 | var slot = slots[name] || (slots[name] = []); |
| 2489 | if (child.tag === "template") { |
| 2490 | slot.push.apply(slot, child.children || []); |
| 2491 | } else { |
| 2492 | slot.push(child); |
| 2493 | } |
| 2494 | } else { |
| 2495 | (slots.default || (slots.default = [])).push(child); |
| 2496 | } |
| 2497 | } |
| 2498 | // ignore slots that contains only whitespace |
| 2499 | for (var name$1 in slots) { |
| 2500 | if (slots[name$1].every(isWhitespace)) { |
| 2501 | delete slots[name$1]; |
| 2502 | } |
| 2503 | } |
| 2504 | return slots; |
| 2505 | } |
| 2506 | |
| 2507 | function isWhitespace(node) { |
| 2508 | return (node.isComment && !node.asyncFactory) || node.text === " "; |
no outgoing calls
no test coverage detected