MCPcopy Index your code
hub / github.com/keepfool/vue-tutorials / transclude

Function transclude

01.GettingStarted/js/vue.js:7636–7667  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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.

Callers 1

lifecycleMixinFunction · 0.70

Calls 8

extractAttrsFunction · 0.70
isTemplateFunction · 0.70
parseTemplateFunction · 0.70
extractContentFunction · 0.70
transcludeTemplateFunction · 0.70
isFragmentFunction · 0.70
prependFunction · 0.70
createAnchorFunction · 0.70

Tested by

no test coverage detected