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

Function parseTemplate

06.Router/basic/js/vue.js:3662–3695  ·  view source on GitHub ↗

* Process the template option and normalizes it into a * a DocumentFragment that can be used as a partial or a * instance template. * * @param {*} template * Possible values include: * - DocumentFragment object * - Node object of type Template * -

(template, shouldClone, raw)

Source from the content-addressed store, hash-verified

3660 */
3661
3662 function parseTemplate(template, shouldClone, raw) {
3663 var node, frag;
3664
3665 // if the template is already a document fragment,
3666 // do nothing
3667 if (isFragment(template)) {
3668 trimNode(template);
3669 return shouldClone ? cloneNode(template) : template;
3670 }
3671
3672 if (typeof template === 'string') {
3673 // id selector
3674 if (!raw && template.charAt(0) === '#') {
3675 // id selector can be cached too
3676 frag = idSelectorCache.get(template);
3677 if (!frag) {
3678 node = document.getElementById(template.slice(1));
3679 if (node) {
3680 frag = nodeToFragment(node);
3681 // save selector to cache
3682 idSelectorCache.put(template, frag);
3683 }
3684 }
3685 } else {
3686 // normal string template
3687 frag = stringToFragment(template, raw);
3688 }
3689 } else if (template.nodeType) {
3690 // a direct node
3691 frag = nodeToFragment(template);
3692 }
3693
3694 return frag && shouldClone ? cloneNode(frag) : frag;
3695 }
3696
3697var template = Object.freeze({
3698 cloneNode: cloneNode,

Callers 6

vue.jsFile · 0.70
FragmentFactoryFunction · 0.70
makeTextNodeLinkFnFunction · 0.70
transcludeFunction · 0.70
transcludeTemplateFunction · 0.70
extractFragmentFunction · 0.70

Calls 5

isFragmentFunction · 0.70
trimNodeFunction · 0.70
cloneNodeFunction · 0.70
nodeToFragmentFunction · 0.70
stringToFragmentFunction · 0.70

Tested by

no test coverage detected