($compileNodes, transcludeFn, maxPriority, ignoreDirective,
previousCompileContext)
| 7488 | //================================ |
| 7489 | |
| 7490 | function compile($compileNodes, transcludeFn, maxPriority, ignoreDirective, |
| 7491 | previousCompileContext) { |
| 7492 | if (!($compileNodes instanceof jqLite)) { |
| 7493 | // jquery always rewraps, whereas we need to preserve the original selector so that we can |
| 7494 | // modify it. |
| 7495 | $compileNodes = jqLite($compileNodes); |
| 7496 | } |
| 7497 | // We can not compile top level text elements since text nodes can be merged and we will |
| 7498 | // not be able to attach scope data to them, so we will wrap them in <span> |
| 7499 | forEach($compileNodes, function(node, index) { |
| 7500 | if (node.nodeType == NODE_TYPE_TEXT && node.nodeValue.match(/\S+/) /* non-empty */ ) { |
| 7501 | $compileNodes[index] = jqLite(node).wrap('<span></span>').parent()[0]; |
| 7502 | } |
| 7503 | }); |
| 7504 | var compositeLinkFn = |
| 7505 | compileNodes($compileNodes, transcludeFn, $compileNodes, |
| 7506 | maxPriority, ignoreDirective, previousCompileContext); |
| 7507 | compile.$$addScopeClass($compileNodes); |
| 7508 | var namespace = null; |
| 7509 | return function publicLinkFn(scope, cloneConnectFn, options) { |
| 7510 | assertArg(scope, 'scope'); |
| 7511 | |
| 7512 | options = options || {}; |
| 7513 | var parentBoundTranscludeFn = options.parentBoundTranscludeFn, |
| 7514 | transcludeControllers = options.transcludeControllers, |
| 7515 | futureParentElement = options.futureParentElement; |
| 7516 | |
| 7517 | // When `parentBoundTranscludeFn` is passed, it is a |
| 7518 | // `controllersBoundTransclude` function (it was previously passed |
| 7519 | // as `transclude` to directive.link) so we must unwrap it to get |
| 7520 | // its `boundTranscludeFn` |
| 7521 | if (parentBoundTranscludeFn && parentBoundTranscludeFn.$$boundTransclude) { |
| 7522 | parentBoundTranscludeFn = parentBoundTranscludeFn.$$boundTransclude; |
| 7523 | } |
| 7524 | |
| 7525 | if (!namespace) { |
| 7526 | namespace = detectNamespaceForChildElements(futureParentElement); |
| 7527 | } |
| 7528 | var $linkNode; |
| 7529 | if (namespace !== 'html') { |
| 7530 | // When using a directive with replace:true and templateUrl the $compileNodes |
| 7531 | // (or a child element inside of them) |
| 7532 | // might change, so we need to recreate the namespace adapted compileNodes |
| 7533 | // for call to the link function. |
| 7534 | // Note: This will already clone the nodes... |
| 7535 | $linkNode = jqLite( |
| 7536 | wrapTemplate(namespace, jqLite('<div>').append($compileNodes).html()) |
| 7537 | ); |
| 7538 | } else if (cloneConnectFn) { |
| 7539 | // important!!: we must call our jqLite.clone() since the jQuery one is trying to be smart |
| 7540 | // and sometimes changes the structure of the DOM. |
| 7541 | $linkNode = JQLitePrototype.clone.call($compileNodes); |
| 7542 | } else { |
| 7543 | $linkNode = $compileNodes; |
| 7544 | } |
| 7545 | |
| 7546 | if (transcludeControllers) { |
| 7547 | for (var controllerName in transcludeControllers) { |
no test coverage detected