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

Function compile

06.Router/basic/js/vue.js:6878–6907  ·  view source on GitHub ↗

* Compile a template and return a reusable composite link * function, which recursively contains more link functions * inside. This top level compile function would normally * be called on instance root nodes, but can also be used * for partial compilation if the partial argument is true

(el, options, partial)

Source from the content-addressed store, hash-verified

6876 */
6877
6878 function compile(el, options, partial) {
6879 // link function for the node itself.
6880 var nodeLinkFn = partial || !options._asComponent ? compileNode(el, options) : null;
6881 // link function for the childNodes
6882 var childLinkFn = !(nodeLinkFn && nodeLinkFn.terminal) && !isScript(el) && el.hasChildNodes() ? compileNodeList(el.childNodes, options) : null;
6883
6884 /**
6885 * A composite linker function to be called on a already
6886 * compiled piece of DOM, which instantiates all directive
6887 * instances.
6888 *
6889 * @param {Vue} vm
6890 * @param {Element|DocumentFragment} el
6891 * @param {Vue} [host] - host vm of transcluded content
6892 * @param {Object} [scope] - v-for scope
6893 * @param {Fragment} [frag] - link context fragment
6894 * @return {Function|undefined}
6895 */
6896
6897 return function compositeLinkFn(vm, el, host, scope, frag) {
6898 // cache childNodes before linking parent, fix #657
6899 var childNodes = toArray(el.childNodes);
6900 // link
6901 var dirs = linkAndCapture(function compositeLinkCapturer() {
6902 if (nodeLinkFn) nodeLinkFn(vm, el, host, scope, frag);
6903 if (childLinkFn) childLinkFn(vm, childNodes, host, scope, frag);
6904 }, vm);
6905 return makeUnlinkFn(vm, dirs);
6906 };
6907 }
6908
6909 /**
6910 * Apply a linker to a vm/element pair and capture the

Callers 3

FragmentFactoryFunction · 0.70
lifecycleMixinFunction · 0.70
lifecycleAPIFunction · 0.70

Calls 6

compileNodeFunction · 0.70
isScriptFunction · 0.70
compileNodeListFunction · 0.70
toArrayFunction · 0.70
linkAndCaptureFunction · 0.70
makeUnlinkFnFunction · 0.70

Tested by

no test coverage detected