MCPcopy
hub / github.com/angular-ui/ui-grid / compileNodes

Function compileNodes

lib/test/angular/1.8.0/angular.js:9799–9907  ·  view source on GitHub ↗

* Compile function matches each node in nodeList against the directives. Once all directives * for a particular node are collected their compile functions are executed. The compile * functions return values - the linking functions - are combined into a composite linking * function, wh

(nodeList, transcludeFn, $rootElement, maxPriority, ignoreDirective,
                            previousCompileContext)

Source from the content-addressed store, hash-verified

9797 * @returns {Function} A composite linking function of all of the matched directives or null.
9798 */
9799 function compileNodes(nodeList, transcludeFn, $rootElement, maxPriority, ignoreDirective,
9800 previousCompileContext) {
9801 var linkFns = [],
9802 // `nodeList` can be either an element's `.childNodes` (live NodeList)
9803 // or a jqLite/jQuery collection or an array
9804 notLiveList = isArray(nodeList) || (nodeList instanceof jqLite),
9805 attrs, directives, nodeLinkFn, childNodes, childLinkFn, linkFnFound, nodeLinkFnFound;
9806
9807
9808 for (var i = 0; i < nodeList.length; i++) {
9809 attrs = new Attributes();
9810
9811 // Support: IE 11 only
9812 // Workaround for #11781 and #14924
9813 if (msie === 11) {
9814 mergeConsecutiveTextNodes(nodeList, i, notLiveList);
9815 }
9816
9817 // We must always refer to `nodeList[i]` hereafter,
9818 // since the nodes can be replaced underneath us.
9819 directives = collectDirectives(nodeList[i], [], attrs, i === 0 ? maxPriority : undefined,
9820 ignoreDirective);
9821
9822 nodeLinkFn = (directives.length)
9823 ? applyDirectivesToNode(directives, nodeList[i], attrs, transcludeFn, $rootElement,
9824 null, [], [], previousCompileContext)
9825 : null;
9826
9827 if (nodeLinkFn && nodeLinkFn.scope) {
9828 compile.$$addScopeClass(attrs.$$element);
9829 }
9830
9831 childLinkFn = (nodeLinkFn && nodeLinkFn.terminal ||
9832 !(childNodes = nodeList[i].childNodes) ||
9833 !childNodes.length)
9834 ? null
9835 : compileNodes(childNodes,
9836 nodeLinkFn ? (
9837 (nodeLinkFn.transcludeOnThisElement || !nodeLinkFn.templateOnThisElement)
9838 && nodeLinkFn.transclude) : transcludeFn);
9839
9840 if (nodeLinkFn || childLinkFn) {
9841 linkFns.push(i, nodeLinkFn, childLinkFn);
9842 linkFnFound = true;
9843 nodeLinkFnFound = nodeLinkFnFound || nodeLinkFn;
9844 }
9845
9846 //use the previous context only for the first element in the virtual group
9847 previousCompileContext = null;
9848 }
9849
9850 // return a linking function if we have found anything, null otherwise
9851 return linkFnFound ? compositeLinkFn : null;
9852
9853 function compositeLinkFn(scope, nodeList, $rootElement, parentBoundTranscludeFn) {
9854 var nodeLinkFn, childLinkFn, node, childScope, i, ii, idx, childBoundTranscludeFn;
9855 var stableNodeList;
9856

Callers 2

compileFunction · 0.70
compileTemplateUrlFunction · 0.70

Calls 4

isArrayFunction · 0.70
collectDirectivesFunction · 0.70
applyDirectivesToNodeFunction · 0.70

Tested by

no test coverage detected