($compileNodes, transcludeFn, maxPriority, ignoreDirective,
previousCompileContext)
| 9629 | //================================ |
| 9630 | |
| 9631 | function compile($compileNodes, transcludeFn, maxPriority, ignoreDirective, |
| 9632 | previousCompileContext) { |
| 9633 | if (!($compileNodes instanceof jqLite)) { |
| 9634 | // jquery always rewraps, whereas we need to preserve the original selector so that we can |
| 9635 | // modify it. |
| 9636 | $compileNodes = jqLite($compileNodes); |
| 9637 | } |
| 9638 | var compositeLinkFn = |
| 9639 | compileNodes($compileNodes, transcludeFn, $compileNodes, |
| 9640 | maxPriority, ignoreDirective, previousCompileContext); |
| 9641 | compile.$$addScopeClass($compileNodes); |
| 9642 | var namespace = null; |
| 9643 | return function publicLinkFn(scope, cloneConnectFn, options) { |
| 9644 | if (!$compileNodes) { |
| 9645 | throw $compileMinErr('multilink', 'This element has already been linked.'); |
| 9646 | } |
| 9647 | assertArg(scope, 'scope'); |
| 9648 | |
| 9649 | if (previousCompileContext && previousCompileContext.needsNewScope) { |
| 9650 | // A parent directive did a replace and a directive on this element asked |
| 9651 | // for transclusion, which caused us to lose a layer of element on which |
| 9652 | // we could hold the new transclusion scope, so we will create it manually |
| 9653 | // here. |
| 9654 | scope = scope.$parent.$new(); |
| 9655 | } |
| 9656 | |
| 9657 | options = options || {}; |
| 9658 | var parentBoundTranscludeFn = options.parentBoundTranscludeFn, |
| 9659 | transcludeControllers = options.transcludeControllers, |
| 9660 | futureParentElement = options.futureParentElement; |
| 9661 | |
| 9662 | // When `parentBoundTranscludeFn` is passed, it is a |
| 9663 | // `controllersBoundTransclude` function (it was previously passed |
| 9664 | // as `transclude` to directive.link) so we must unwrap it to get |
| 9665 | // its `boundTranscludeFn` |
| 9666 | if (parentBoundTranscludeFn && parentBoundTranscludeFn.$$boundTransclude) { |
| 9667 | parentBoundTranscludeFn = parentBoundTranscludeFn.$$boundTransclude; |
| 9668 | } |
| 9669 | |
| 9670 | if (!namespace) { |
| 9671 | namespace = detectNamespaceForChildElements(futureParentElement); |
| 9672 | } |
| 9673 | var $linkNode; |
| 9674 | if (namespace !== 'html') { |
| 9675 | // When using a directive with replace:true and templateUrl the $compileNodes |
| 9676 | // (or a child element inside of them) |
| 9677 | // might change, so we need to recreate the namespace adapted compileNodes |
| 9678 | // for call to the link function. |
| 9679 | // Note: This will already clone the nodes... |
| 9680 | $linkNode = jqLite( |
| 9681 | wrapTemplate(namespace, jqLite('<div></div>').append($compileNodes).html()) |
| 9682 | ); |
| 9683 | } else if (cloneConnectFn) { |
| 9684 | // important!!: we must call our jqLite.clone() since the jQuery one is trying to be smart |
| 9685 | // and sometimes changes the structure of the DOM. |
| 9686 | $linkNode = JQLitePrototype.clone.call($compileNodes); |
| 9687 | } else { |
| 9688 | $linkNode = $compileNodes; |
no test coverage detected