* 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)
| 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 |
no test coverage detected