MCPcopy
hub / github.com/angular-ui/ui-grid / compileTemplateUrl

Function compileTemplateUrl

lib/test/angular/1.6.7/angular.js:10247–10364  ·  view source on GitHub ↗
(directives, $compileNode, tAttrs,
        $rootElement, childTranscludeFn, preLinkFns, postLinkFns, previousCompileContext)

Source from the content-addressed store, hash-verified

10245
10246
10247 function compileTemplateUrl(directives, $compileNode, tAttrs,
10248 $rootElement, childTranscludeFn, preLinkFns, postLinkFns, previousCompileContext) {
10249 var linkQueue = [],
10250 afterTemplateNodeLinkFn,
10251 afterTemplateChildLinkFn,
10252 beforeTemplateCompileNode = $compileNode[0],
10253 origAsyncDirective = directives.shift(),
10254 derivedSyncDirective = inherit(origAsyncDirective, {
10255 templateUrl: null, transclude: null, replace: null, $$originalDirective: origAsyncDirective
10256 }),
10257 templateUrl = (isFunction(origAsyncDirective.templateUrl))
10258 ? origAsyncDirective.templateUrl($compileNode, tAttrs)
10259 : origAsyncDirective.templateUrl,
10260 templateNamespace = origAsyncDirective.templateNamespace;
10261
10262 $compileNode.empty();
10263
10264 $templateRequest(templateUrl)
10265 .then(function(content) {
10266 var compileNode, tempTemplateAttrs, $template, childBoundTranscludeFn;
10267
10268 content = denormalizeTemplate(content);
10269
10270 if (origAsyncDirective.replace) {
10271 if (jqLiteIsTextNode(content)) {
10272 $template = [];
10273 } else {
10274 $template = removeComments(wrapTemplate(templateNamespace, trim(content)));
10275 }
10276 compileNode = $template[0];
10277
10278 if ($template.length !== 1 || compileNode.nodeType !== NODE_TYPE_ELEMENT) {
10279 throw $compileMinErr('tplrt',
10280 'Template for directive \'{0}\' must have exactly one root element. {1}',
10281 origAsyncDirective.name, templateUrl);
10282 }
10283
10284 tempTemplateAttrs = {$attr: {}};
10285 replaceWith($rootElement, $compileNode, compileNode);
10286 var templateDirectives = collectDirectives(compileNode, [], tempTemplateAttrs);
10287
10288 if (isObject(origAsyncDirective.scope)) {
10289 // the original directive that caused the template to be loaded async required
10290 // an isolate scope
10291 markDirectiveScope(templateDirectives, true);
10292 }
10293 directives = templateDirectives.concat(directives);
10294 mergeTemplateAttributes(tAttrs, tempTemplateAttrs);
10295 } else {
10296 compileNode = beforeTemplateCompileNode;
10297 $compileNode.html(content);
10298 }
10299
10300 directives.unshift(derivedSyncDirective);
10301
10302 afterTemplateNodeLinkFn = applyDirectivesToNode(directives, compileNode, tAttrs,
10303 childTranscludeFn, $compileNode, origAsyncDirective, preLinkFns, postLinkFns,
10304 previousCompileContext);

Callers 1

applyDirectivesToNodeFunction · 0.70

Calls 15

inheritFunction · 0.70
isFunctionFunction · 0.70
jqLiteIsTextNodeFunction · 0.70
removeCommentsFunction · 0.70
wrapTemplateFunction · 0.70
trimFunction · 0.70
replaceWithFunction · 0.70
collectDirectivesFunction · 0.70
isObjectFunction · 0.70
markDirectiveScopeFunction · 0.70
mergeTemplateAttributesFunction · 0.70
applyDirectivesToNodeFunction · 0.70

Tested by

no test coverage detected