MCPcopy Index your code
hub / github.com/angular-ui/ui-router / compile

Function compile

test/angular/1.5/angular.js:8611–8693  ·  view source on GitHub ↗
($compileNodes, transcludeFn, maxPriority, ignoreDirective,
                        previousCompileContext)

Source from the content-addressed store, hash-verified

8609 //================================
8610
8611 function compile($compileNodes, transcludeFn, maxPriority, ignoreDirective,
8612 previousCompileContext) {
8613 if (!($compileNodes instanceof jqLite)) {
8614 // jquery always rewraps, whereas we need to preserve the original selector so that we can
8615 // modify it.
8616 $compileNodes = jqLite($compileNodes);
8617 }
8618
8619 var NOT_EMPTY = /\S+/;
8620
8621 // We can not compile top level text elements since text nodes can be merged and we will
8622 // not be able to attach scope data to them, so we will wrap them in <span>
8623 for (var i = 0, len = $compileNodes.length; i < len; i++) {
8624 var domNode = $compileNodes[i];
8625
8626 if (domNode.nodeType === NODE_TYPE_TEXT && domNode.nodeValue.match(NOT_EMPTY) /* non-empty */) {
8627 jqLiteWrapNode(domNode, $compileNodes[i] = window.document.createElement('span'));
8628 }
8629 }
8630
8631 var compositeLinkFn =
8632 compileNodes($compileNodes, transcludeFn, $compileNodes,
8633 maxPriority, ignoreDirective, previousCompileContext);
8634 compile.$$addScopeClass($compileNodes);
8635 var namespace = null;
8636 return function publicLinkFn(scope, cloneConnectFn, options) {
8637 assertArg(scope, 'scope');
8638
8639 if (previousCompileContext && previousCompileContext.needsNewScope) {
8640 // A parent directive did a replace and a directive on this element asked
8641 // for transclusion, which caused us to lose a layer of element on which
8642 // we could hold the new transclusion scope, so we will create it manually
8643 // here.
8644 scope = scope.$parent.$new();
8645 }
8646
8647 options = options || {};
8648 var parentBoundTranscludeFn = options.parentBoundTranscludeFn,
8649 transcludeControllers = options.transcludeControllers,
8650 futureParentElement = options.futureParentElement;
8651
8652 // When `parentBoundTranscludeFn` is passed, it is a
8653 // `controllersBoundTransclude` function (it was previously passed
8654 // as `transclude` to directive.link) so we must unwrap it to get
8655 // its `boundTranscludeFn`
8656 if (parentBoundTranscludeFn && parentBoundTranscludeFn.$$boundTransclude) {
8657 parentBoundTranscludeFn = parentBoundTranscludeFn.$$boundTransclude;
8658 }
8659
8660 if (!namespace) {
8661 namespace = detectNamespaceForChildElements(futureParentElement);
8662 }
8663 var $linkNode;
8664 if (namespace !== 'html') {
8665 // When using a directive with replace:true and templateUrl the $compileNodes
8666 // (or a child element inside of them)
8667 // might change, so we need to recreate the namespace adapted compileNodes
8668 // for call to the link function.

Callers 2

doBootstrapFunction · 0.70
compilationGeneratorFunction · 0.70

Calls 7

matchMethod · 0.80
jqLiteWrapNodeFunction · 0.70
compileNodesFunction · 0.70
assertArgFunction · 0.70
wrapTemplateFunction · 0.70
compositeLinkFnFunction · 0.70

Tested by

no test coverage detected