($compileNodes, transcludeFn, maxPriority, ignoreDirective,
previousCompileContext)
| 9694 | //================================ |
| 9695 | |
| 9696 | function compile($compileNodes, transcludeFn, maxPriority, ignoreDirective, |
| 9697 | previousCompileContext) { |
| 9698 | if (!($compileNodes instanceof jqLite)) { |
| 9699 | // jquery always rewraps, whereas we need to preserve the original selector so that we can |
| 9700 | // modify it. |
| 9701 | $compileNodes = jqLite($compileNodes); |
| 9702 | } |
| 9703 | var compositeLinkFn = |
| 9704 | compileNodes($compileNodes, transcludeFn, $compileNodes, |
| 9705 | maxPriority, ignoreDirective, previousCompileContext); |
| 9706 | compile.$$addScopeClass($compileNodes); |
| 9707 | var namespace = null; |
| 9708 | return function publicLinkFn(scope, cloneConnectFn, options) { |
| 9709 | if (!$compileNodes) { |
| 9710 | throw $compileMinErr('multilink', 'This element has already been linked.'); |
| 9711 | } |
| 9712 | assertArg(scope, 'scope'); |
| 9713 | |
| 9714 | if (previousCompileContext && previousCompileContext.needsNewScope) { |
| 9715 | // A parent directive did a replace and a directive on this element asked |
| 9716 | // for transclusion, which caused us to lose a layer of element on which |
| 9717 | // we could hold the new transclusion scope, so we will create it manually |
| 9718 | // here. |
| 9719 | scope = scope.$parent.$new(); |
| 9720 | } |
| 9721 | |
| 9722 | options = options || {}; |
| 9723 | var parentBoundTranscludeFn = options.parentBoundTranscludeFn, |
| 9724 | transcludeControllers = options.transcludeControllers, |
| 9725 | futureParentElement = options.futureParentElement; |
| 9726 | |
| 9727 | // When `parentBoundTranscludeFn` is passed, it is a |
| 9728 | // `controllersBoundTransclude` function (it was previously passed |
| 9729 | // as `transclude` to directive.link) so we must unwrap it to get |
| 9730 | // its `boundTranscludeFn` |
| 9731 | if (parentBoundTranscludeFn && parentBoundTranscludeFn.$$boundTransclude) { |
| 9732 | parentBoundTranscludeFn = parentBoundTranscludeFn.$$boundTransclude; |
| 9733 | } |
| 9734 | |
| 9735 | if (!namespace) { |
| 9736 | namespace = detectNamespaceForChildElements(futureParentElement); |
| 9737 | } |
| 9738 | var $linkNode; |
| 9739 | if (namespace !== 'html') { |
| 9740 | // When using a directive with replace:true and templateUrl the $compileNodes |
| 9741 | // (or a child element inside of them) |
| 9742 | // might change, so we need to recreate the namespace adapted compileNodes |
| 9743 | // for call to the link function. |
| 9744 | // Note: This will already clone the nodes... |
| 9745 | $linkNode = jqLite( |
| 9746 | wrapTemplate(namespace, jqLite('<div></div>').append($compileNodes).html()) |
| 9747 | ); |
| 9748 | } else if (cloneConnectFn) { |
| 9749 | // important!!: we must call our jqLite.clone() since the jQuery one is trying to be smart |
| 9750 | // and sometimes changes the structure of the DOM. |
| 9751 | $linkNode = JQLitePrototype.clone.call($compileNodes); |
| 9752 | } else { |
| 9753 | $linkNode = $compileNodes; |
no test coverage detected