(scope, nodeList, $rootElement, parentBoundTranscludeFn)
| 8177 | return linkFnFound ? compositeLinkFn : null; |
| 8178 | |
| 8179 | function compositeLinkFn(scope, nodeList, $rootElement, parentBoundTranscludeFn) { |
| 8180 | var nodeLinkFn, childLinkFn, node, childScope, i, ii, idx, childBoundTranscludeFn; |
| 8181 | var stableNodeList; |
| 8182 | |
| 8183 | |
| 8184 | if (nodeLinkFnFound) { |
| 8185 | // copy nodeList so that if a nodeLinkFn removes or adds an element at this DOM level our |
| 8186 | // offsets don't get screwed up |
| 8187 | var nodeListLength = nodeList.length; |
| 8188 | stableNodeList = new Array(nodeListLength); |
| 8189 | |
| 8190 | // create a sparse array by only copying the elements which have a linkFn |
| 8191 | for (i = 0; i < linkFns.length; i+=3) { |
| 8192 | idx = linkFns[i]; |
| 8193 | stableNodeList[idx] = nodeList[idx]; |
| 8194 | } |
| 8195 | } else { |
| 8196 | stableNodeList = nodeList; |
| 8197 | } |
| 8198 | |
| 8199 | for (i = 0, ii = linkFns.length; i < ii;) { |
| 8200 | node = stableNodeList[linkFns[i++]]; |
| 8201 | nodeLinkFn = linkFns[i++]; |
| 8202 | childLinkFn = linkFns[i++]; |
| 8203 | |
| 8204 | if (nodeLinkFn) { |
| 8205 | if (nodeLinkFn.scope) { |
| 8206 | childScope = scope.$new(); |
| 8207 | compile.$$addScopeInfo(jqLite(node), childScope); |
| 8208 | } else { |
| 8209 | childScope = scope; |
| 8210 | } |
| 8211 | |
| 8212 | if (nodeLinkFn.transcludeOnThisElement) { |
| 8213 | childBoundTranscludeFn = createBoundTranscludeFn( |
| 8214 | scope, nodeLinkFn.transclude, parentBoundTranscludeFn); |
| 8215 | |
| 8216 | } else if (!nodeLinkFn.templateOnThisElement && parentBoundTranscludeFn) { |
| 8217 | childBoundTranscludeFn = parentBoundTranscludeFn; |
| 8218 | |
| 8219 | } else if (!parentBoundTranscludeFn && transcludeFn) { |
| 8220 | childBoundTranscludeFn = createBoundTranscludeFn(scope, transcludeFn); |
| 8221 | |
| 8222 | } else { |
| 8223 | childBoundTranscludeFn = null; |
| 8224 | } |
| 8225 | |
| 8226 | nodeLinkFn(childLinkFn, childScope, node, $rootElement, childBoundTranscludeFn); |
| 8227 | |
| 8228 | } else if (childLinkFn) { |
| 8229 | childLinkFn(scope, node.childNodes, undefined, parentBoundTranscludeFn); |
| 8230 | } |
| 8231 | } |
| 8232 | } |
| 8233 | } |
| 8234 | |
| 8235 | function createBoundTranscludeFn(scope, transcludeFn, previousBoundTranscludeFn) { |
no test coverage detected