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

Function FragmentFactory

06.Router/basic/js/vue.js:3941–3966  ·  view source on GitHub ↗

* A factory that can be used to create instances of a * fragment. Caches the compiled linker if possible. * * @param {Vue} vm * @param {Element|String} el

(vm, el)

Source from the content-addressed store, hash-verified

3939 * @param {Element|String} el
3940 */
3941 function FragmentFactory(vm, el) {
3942 this.vm = vm;
3943 var template;
3944 var isString = typeof el === 'string';
3945 if (isString || isTemplate(el) && !el.hasAttribute('v-if')) {
3946 template = parseTemplate(el, true);
3947 } else {
3948 template = document.createDocumentFragment();
3949 template.appendChild(el);
3950 }
3951 this.template = template;
3952 // linker can be cached, but only for components
3953 var linker;
3954 var cid = vm.constructor.cid;
3955 if (cid > 0) {
3956 var cacheId = cid + (isString ? el : getOuterHTML(el));
3957 linker = linkerCache.get(cacheId);
3958 if (!linker) {
3959 linker = compile(template, vm.$options, true);
3960 linkerCache.put(cacheId, linker);
3961 }
3962 } else {
3963 linker = compile(template, vm.$options, true);
3964 }
3965 this.linker = linker;
3966 }
3967
3968 /**
3969 * Create a fragment instance with given host and scope.

Callers

nothing calls this directly

Calls 4

isTemplateFunction · 0.70
parseTemplateFunction · 0.70
getOuterHTMLFunction · 0.70
compileFunction · 0.70

Tested by

no test coverage detected