MCPcopy Create free account
hub / github.com/OpenReservation/OpenReservation / compile

Function compile

OpenReservation/wwwroot/Scripts/angular.js:8075–8165  ·  view source on GitHub ↗
($compileNodes,
                    transcludeFn,
                    maxPriority,
                    ignoreDirective,
                    previousCompileContext)

Source from the content-addressed store, hash-verified

8073 //================================
8074
8075 function compile($compileNodes,
8076 transcludeFn,
8077 maxPriority,
8078 ignoreDirective,
8079 previousCompileContext) {
8080 if (!($compileNodes instanceof jqLite)) {
8081 // jquery always rewraps, whereas we need to preserve the original selector so that we can
8082 // modify it.
8083 $compileNodes = jqLite($compileNodes);
8084 }
8085
8086 var NOT_EMPTY = /\S+/;
8087
8088 // We can not compile top level text elements since text nodes can be merged and we will
8089 // not be able to attach scope data to them, so we will wrap them in <span>
8090 for (var i = 0, len = $compileNodes.length; i < len; i++) {
8091 var domNode = $compileNodes[i];
8092
8093 if (domNode.nodeType === NODE_TYPE_TEXT && domNode.nodeValue.match(NOT_EMPTY) /* non-empty */) {
8094 jqLiteWrapNode(domNode, $compileNodes[i] = document.createElement('span'));
8095 }
8096 }
8097
8098 var compositeLinkFn =
8099 compileNodes($compileNodes,
8100 transcludeFn,
8101 $compileNodes,
8102 maxPriority,
8103 ignoreDirective,
8104 previousCompileContext);
8105 compile.$$addScopeClass($compileNodes);
8106 var namespace = null;
8107 return function publicLinkFn(scope, cloneConnectFn, options) {
8108 assertArg(scope, 'scope');
8109
8110 if (previousCompileContext && previousCompileContext.needsNewScope) {
8111 // A parent directive did a replace and a directive on this element asked
8112 // for transclusion, which caused us to lose a layer of element on which
8113 // we could hold the new transclusion scope, so we will create it manually
8114 // here.
8115 scope = scope.$parent.$new();
8116 }
8117
8118 options = options || {};
8119 var parentBoundTranscludeFn = options.parentBoundTranscludeFn,
8120 transcludeControllers = options.transcludeControllers,
8121 futureParentElement = options.futureParentElement;
8122
8123 // When `parentBoundTranscludeFn` is passed, it is a
8124 // `controllersBoundTransclude` function (it was previously passed
8125 // as `transclude` to directive.link) so we must unwrap it to get
8126 // its `boundTranscludeFn`
8127 if (parentBoundTranscludeFn && parentBoundTranscludeFn.$$boundTransclude) {
8128 parentBoundTranscludeFn = parentBoundTranscludeFn.$$boundTransclude;
8129 }
8130
8131 if (!namespace) {
8132 namespace = detectNamespaceForChildElements(futureParentElement);

Callers 4

jquery-1.10.2.jsFile · 0.85
selectFunction · 0.85
doBootstrapFunction · 0.85
compilationGeneratorFunction · 0.85

Calls 6

jqLiteWrapNodeFunction · 0.85
compileNodesFunction · 0.85
assertArgFunction · 0.85
wrapTemplateFunction · 0.85
compositeLinkFnFunction · 0.85

Tested by

no test coverage detected