($compileNodes, transcludeFn, maxPriority, ignoreDirective,
previousCompileContext)
| 9144 | //================================ |
| 9145 | |
| 9146 | function compile($compileNodes, transcludeFn, maxPriority, ignoreDirective, |
| 9147 | previousCompileContext) { |
| 9148 | if (!($compileNodes instanceof jqLite)) { |
| 9149 | // jquery always rewraps, whereas we need to preserve the original selector so that we can |
| 9150 | // modify it. |
| 9151 | $compileNodes = jqLite($compileNodes); |
| 9152 | } |
| 9153 | var compositeLinkFn = |
| 9154 | compileNodes($compileNodes, transcludeFn, $compileNodes, |
| 9155 | maxPriority, ignoreDirective, previousCompileContext); |
| 9156 | compile.$$addScopeClass($compileNodes); |
| 9157 | var namespace = null; |
| 9158 | return function publicLinkFn(scope, cloneConnectFn, options) { |
| 9159 | if (!$compileNodes) { |
| 9160 | throw $compileMinErr('multilink', 'This element has already been linked.'); |
| 9161 | } |
| 9162 | assertArg(scope, 'scope'); |
| 9163 | |
| 9164 | if (previousCompileContext && previousCompileContext.needsNewScope) { |
| 9165 | // A parent directive did a replace and a directive on this element asked |
| 9166 | // for transclusion, which caused us to lose a layer of element on which |
| 9167 | // we could hold the new transclusion scope, so we will create it manually |
| 9168 | // here. |
| 9169 | scope = scope.$parent.$new(); |
| 9170 | } |
| 9171 | |
| 9172 | options = options || {}; |
| 9173 | var parentBoundTranscludeFn = options.parentBoundTranscludeFn, |
| 9174 | transcludeControllers = options.transcludeControllers, |
| 9175 | futureParentElement = options.futureParentElement; |
| 9176 | |
| 9177 | // When `parentBoundTranscludeFn` is passed, it is a |
| 9178 | // `controllersBoundTransclude` function (it was previously passed |
| 9179 | // as `transclude` to directive.link) so we must unwrap it to get |
| 9180 | // its `boundTranscludeFn` |
| 9181 | if (parentBoundTranscludeFn && parentBoundTranscludeFn.$$boundTransclude) { |
| 9182 | parentBoundTranscludeFn = parentBoundTranscludeFn.$$boundTransclude; |
| 9183 | } |
| 9184 | |
| 9185 | if (!namespace) { |
| 9186 | namespace = detectNamespaceForChildElements(futureParentElement); |
| 9187 | } |
| 9188 | var $linkNode; |
| 9189 | if (namespace !== 'html') { |
| 9190 | // When using a directive with replace:true and templateUrl the $compileNodes |
| 9191 | // (or a child element inside of them) |
| 9192 | // might change, so we need to recreate the namespace adapted compileNodes |
| 9193 | // for call to the link function. |
| 9194 | // Note: This will already clone the nodes... |
| 9195 | $linkNode = jqLite( |
| 9196 | wrapTemplate(namespace, jqLite('<div></div>').append($compileNodes).html()) |
| 9197 | ); |
| 9198 | } else if (cloneConnectFn) { |
| 9199 | // important!!: we must call our jqLite.clone() since the jQuery one is trying to be smart |
| 9200 | // and sometimes changes the structure of the DOM. |
| 9201 | $linkNode = JQLitePrototype.clone.call($compileNodes); |
| 9202 | } else { |
| 9203 | $linkNode = $compileNodes; |
no test coverage detected