* Process an element or a DocumentFragment based on a * instance option object. This allows us to transclude * a template node/fragment before the instance is created, * so the processed fragment can then be cloned and reused * in v-for. * * @param {Element} el * @param {Object}
(el, options)
| 7634 | */ |
| 7635 | |
| 7636 | function transclude(el, options) { |
| 7637 | // extract container attributes to pass them down |
| 7638 | // to compiler, because they need to be compiled in |
| 7639 | // parent scope. we are mutating the options object here |
| 7640 | // assuming the same object will be used for compile |
| 7641 | // right after this. |
| 7642 | if (options) { |
| 7643 | options._containerAttrs = extractAttrs(el); |
| 7644 | } |
| 7645 | // for template tags, what we want is its content as |
| 7646 | // a documentFragment (for fragment instances) |
| 7647 | if (isTemplate(el)) { |
| 7648 | el = parseTemplate(el); |
| 7649 | } |
| 7650 | if (options) { |
| 7651 | if (options._asComponent && !options.template) { |
| 7652 | options.template = '<slot></slot>'; |
| 7653 | } |
| 7654 | if (options.template) { |
| 7655 | options._content = extractContent(el); |
| 7656 | el = transcludeTemplate(el, options); |
| 7657 | } |
| 7658 | } |
| 7659 | if (isFragment(el)) { |
| 7660 | // anchors for fragment instance |
| 7661 | // passing in `persist: true` to avoid them being |
| 7662 | // discarded by IE during template cloning |
| 7663 | prepend(createAnchor('v-start', true), el); |
| 7664 | el.appendChild(createAnchor('v-end', true)); |
| 7665 | } |
| 7666 | return el; |
| 7667 | } |
| 7668 | |
| 7669 | /** |
| 7670 | * Process the template option. |
no test coverage detected