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

Function compile

lib/test/angular/1.5.0/angular.js:8027–8109  ·  view source on GitHub ↗
($compileNodes, transcludeFn, maxPriority, ignoreDirective,
                        previousCompileContext)

Source from the content-addressed store, hash-verified

8025 //================================
8026
8027 function compile($compileNodes, transcludeFn, maxPriority, ignoreDirective,
8028 previousCompileContext) {
8029 if (!($compileNodes instanceof jqLite)) {
8030 // jquery always rewraps, whereas we need to preserve the original selector so that we can
8031 // modify it.
8032 $compileNodes = jqLite($compileNodes);
8033 }
8034
8035 var NOT_EMPTY = /\S+/;
8036
8037 // We can not compile top level text elements since text nodes can be merged and we will
8038 // not be able to attach scope data to them, so we will wrap them in <span>
8039 for (var i = 0, len = $compileNodes.length; i < len; i++) {
8040 var domNode = $compileNodes[i];
8041
8042 if (domNode.nodeType === NODE_TYPE_TEXT && domNode.nodeValue.match(NOT_EMPTY) /* non-empty */) {
8043 jqLiteWrapNode(domNode, $compileNodes[i] = document.createElement('span'));
8044 }
8045 }
8046
8047 var compositeLinkFn =
8048 compileNodes($compileNodes, transcludeFn, $compileNodes,
8049 maxPriority, ignoreDirective, previousCompileContext);
8050 compile.$$addScopeClass($compileNodes);
8051 var namespace = null;
8052 return function publicLinkFn(scope, cloneConnectFn, options) {
8053 assertArg(scope, 'scope');
8054
8055 if (previousCompileContext && previousCompileContext.needsNewScope) {
8056 // A parent directive did a replace and a directive on this element asked
8057 // for transclusion, which caused us to lose a layer of element on which
8058 // we could hold the new transclusion scope, so we will create it manually
8059 // here.
8060 scope = scope.$parent.$new();
8061 }
8062
8063 options = options || {};
8064 var parentBoundTranscludeFn = options.parentBoundTranscludeFn,
8065 transcludeControllers = options.transcludeControllers,
8066 futureParentElement = options.futureParentElement;
8067
8068 // When `parentBoundTranscludeFn` is passed, it is a
8069 // `controllersBoundTransclude` function (it was previously passed
8070 // as `transclude` to directive.link) so we must unwrap it to get
8071 // its `boundTranscludeFn`
8072 if (parentBoundTranscludeFn && parentBoundTranscludeFn.$$boundTransclude) {
8073 parentBoundTranscludeFn = parentBoundTranscludeFn.$$boundTransclude;
8074 }
8075
8076 if (!namespace) {
8077 namespace = detectNamespaceForChildElements(futureParentElement);
8078 }
8079 var $linkNode;
8080 if (namespace !== 'html') {
8081 // When using a directive with replace:true and templateUrl the $compileNodes
8082 // (or a child element inside of them)
8083 // might change, so we need to recreate the namespace adapted compileNodes
8084 // for call to the link function.

Callers 2

doBootstrapFunction · 0.70
compilationGeneratorFunction · 0.70

Calls 6

jqLiteWrapNodeFunction · 0.70
compileNodesFunction · 0.70
assertArgFunction · 0.70
wrapTemplateFunction · 0.70
compositeLinkFnFunction · 0.70

Tested by

no test coverage detected