($compileNodes, transcludeFn, maxPriority, ignoreDirective,
previousCompileContext)
| 6952 | //================================ |
| 6953 | |
| 6954 | function compile($compileNodes, transcludeFn, maxPriority, ignoreDirective, |
| 6955 | previousCompileContext) { |
| 6956 | if (!($compileNodes instanceof jqLite)) { |
| 6957 | // jquery always rewraps, whereas we need to preserve the original selector so that we can |
| 6958 | // modify it. |
| 6959 | $compileNodes = jqLite($compileNodes); |
| 6960 | } |
| 6961 | // We can not compile top level text elements since text nodes can be merged and we will |
| 6962 | // not be able to attach scope data to them, so we will wrap them in <span> |
| 6963 | forEach($compileNodes, function(node, index) { |
| 6964 | if (node.nodeType == NODE_TYPE_TEXT && node.nodeValue.match(/\S+/) /* non-empty */ ) { |
| 6965 | $compileNodes[index] = jqLite(node).wrap('<span></span>').parent()[0]; |
| 6966 | } |
| 6967 | }); |
| 6968 | var compositeLinkFn = |
| 6969 | compileNodes($compileNodes, transcludeFn, $compileNodes, |
| 6970 | maxPriority, ignoreDirective, previousCompileContext); |
| 6971 | compile.$$addScopeClass($compileNodes); |
| 6972 | var namespace = null; |
| 6973 | return function publicLinkFn(scope, cloneConnectFn, options) { |
| 6974 | assertArg(scope, 'scope'); |
| 6975 | |
| 6976 | options = options || {}; |
| 6977 | var parentBoundTranscludeFn = options.parentBoundTranscludeFn, |
| 6978 | transcludeControllers = options.transcludeControllers, |
| 6979 | futureParentElement = options.futureParentElement; |
| 6980 | |
| 6981 | // When `parentBoundTranscludeFn` is passed, it is a |
| 6982 | // `controllersBoundTransclude` function (it was previously passed |
| 6983 | // as `transclude` to directive.link) so we must unwrap it to get |
| 6984 | // its `boundTranscludeFn` |
| 6985 | if (parentBoundTranscludeFn && parentBoundTranscludeFn.$$boundTransclude) { |
| 6986 | parentBoundTranscludeFn = parentBoundTranscludeFn.$$boundTransclude; |
| 6987 | } |
| 6988 | |
| 6989 | if (!namespace) { |
| 6990 | namespace = detectNamespaceForChildElements(futureParentElement); |
| 6991 | } |
| 6992 | var $linkNode; |
| 6993 | if (namespace !== 'html') { |
| 6994 | // When using a directive with replace:true and templateUrl the $compileNodes |
| 6995 | // (or a child element inside of them) |
| 6996 | // might change, so we need to recreate the namespace adapted compileNodes |
| 6997 | // for call to the link function. |
| 6998 | // Note: This will already clone the nodes... |
| 6999 | $linkNode = jqLite( |
| 7000 | wrapTemplate(namespace, jqLite('<div>').append($compileNodes).html()) |
| 7001 | ); |
| 7002 | } else if (cloneConnectFn) { |
| 7003 | // important!!: we must call our jqLite.clone() since the jQuery one is trying to be smart |
| 7004 | // and sometimes changes the structure of the DOM. |
| 7005 | $linkNode = JQLitePrototype.clone.call($compileNodes); |
| 7006 | } else { |
| 7007 | $linkNode = $compileNodes; |
| 7008 | } |
| 7009 | |
| 7010 | if (transcludeControllers) { |
| 7011 | for (var controllerName in transcludeControllers) { |
no test coverage detected