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

Function compileTemplateUrl

test/angular/1.7/angular.js:10842–10959  ·  view source on GitHub ↗
(directives, $compileNode, tAttrs,
        $rootElement, childTranscludeFn, preLinkFns, postLinkFns, previousCompileContext)

Source from the content-addressed store, hash-verified

10840
10841
10842 function compileTemplateUrl(directives, $compileNode, tAttrs,
10843 $rootElement, childTranscludeFn, preLinkFns, postLinkFns, previousCompileContext) {
10844 var linkQueue = [],
10845 afterTemplateNodeLinkFn,
10846 afterTemplateChildLinkFn,
10847 beforeTemplateCompileNode = $compileNode[0],
10848 origAsyncDirective = directives.shift(),
10849 derivedSyncDirective = inherit(origAsyncDirective, {
10850 templateUrl: null, transclude: null, replace: null, $$originalDirective: origAsyncDirective
10851 }),
10852 templateUrl = (isFunction(origAsyncDirective.templateUrl))
10853 ? origAsyncDirective.templateUrl($compileNode, tAttrs)
10854 : origAsyncDirective.templateUrl,
10855 templateNamespace = origAsyncDirective.templateNamespace;
10856
10857 $compileNode.empty();
10858
10859 $templateRequest(templateUrl)
10860 .then(function(content) {
10861 var compileNode, tempTemplateAttrs, $template, childBoundTranscludeFn;
10862
10863 content = denormalizeTemplate(content);
10864
10865 if (origAsyncDirective.replace) {
10866 if (jqLiteIsTextNode(content)) {
10867 $template = [];
10868 } else {
10869 $template = removeComments(wrapTemplate(templateNamespace, trim(content)));
10870 }
10871 compileNode = $template[0];
10872
10873 if ($template.length !== 1 || compileNode.nodeType !== NODE_TYPE_ELEMENT) {
10874 throw $compileMinErr('tplrt',
10875 'Template for directive \'{0}\' must have exactly one root element. {1}',
10876 origAsyncDirective.name, templateUrl);
10877 }
10878
10879 tempTemplateAttrs = {$attr: {}};
10880 replaceWith($rootElement, $compileNode, compileNode);
10881 var templateDirectives = collectDirectives(compileNode, [], tempTemplateAttrs);
10882
10883 if (isObject(origAsyncDirective.scope)) {
10884 // the original directive that caused the template to be loaded async required
10885 // an isolate scope
10886 markDirectiveScope(templateDirectives, true);
10887 }
10888 directives = templateDirectives.concat(directives);
10889 mergeTemplateAttributes(tAttrs, tempTemplateAttrs);
10890 } else {
10891 compileNode = beforeTemplateCompileNode;
10892 $compileNode.html(content);
10893 }
10894
10895 directives.unshift(derivedSyncDirective);
10896
10897 afterTemplateNodeLinkFn = applyDirectivesToNode(directives, compileNode, tAttrs,
10898 childTranscludeFn, $compileNode, origAsyncDirective, preLinkFns, postLinkFns,
10899 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