* Scan and determine slot content distribution. * We do this during transclusion instead at compile time so that * the distribution is decoupled from the compilation order of * the slots. * * @param {Element|DocumentFragment} template * @param {Element} content * @param {Vue} vm
(vm, content)
| 7768 | */ |
| 7769 | |
| 7770 | function resolveSlots(vm, content) { |
| 7771 | if (!content) { |
| 7772 | return; |
| 7773 | } |
| 7774 | var contents = vm._slotContents = Object.create(null); |
| 7775 | var el, name; |
| 7776 | for (var i = 0, l = content.children.length; i < l; i++) { |
| 7777 | el = content.children[i]; |
| 7778 | /* eslint-disable no-cond-assign */ |
| 7779 | if (name = el.getAttribute('slot')) { |
| 7780 | (contents[name] || (contents[name] = [])).push(el); |
| 7781 | } |
| 7782 | /* eslint-enable no-cond-assign */ |
| 7783 | if ('development' !== 'production' && getBindAttr(el, 'slot')) { |
| 7784 | warn('The "slot" attribute must be static.', vm.$parent); |
| 7785 | } |
| 7786 | } |
| 7787 | for (name in contents) { |
| 7788 | contents[name] = extractFragment(contents[name], content); |
| 7789 | } |
| 7790 | if (content.hasChildNodes()) { |
| 7791 | var nodes = content.childNodes; |
| 7792 | if (nodes.length === 1 && nodes[0].nodeType === 3 && !nodes[0].data.trim()) { |
| 7793 | return; |
| 7794 | } |
| 7795 | contents['default'] = extractFragment(content.childNodes, content); |
| 7796 | } |
| 7797 | } |
| 7798 | |
| 7799 | /** |
| 7800 | * Extract qualified content nodes from a node list. |
no test coverage detected