fix(templateRequest): allow empty html template

allow empty html template and not throw error

Closes #9581
This commit is contained in:
Michal Cieplucha
2014-10-21 11:41:19 +02:00
committed by Vojta Jina
parent 38d12de661
commit 52ceec2229
4 changed files with 7 additions and 11 deletions

View File

@@ -48,10 +48,6 @@ function $TemplateRequestProvider() {
return $http.get(tpl, httpOptions)
.then(function(response) {
var html = response.data;
if (!html || html.length === 0) {
return handleError();
}
self.totalPendingRequests--;
$templateCache.put(tpl, html);
return html;

View File

@@ -43,7 +43,7 @@ describe('$templateRequest', function() {
}).toThrowMinErr('$compile', 'tpload', 'Failed to load template: tpl.html');
}));
it('should throw an error when the template is empty',
it('should not throw an error when the template is empty',
inject(function($rootScope, $templateRequest, $httpBackend) {
$httpBackend.expectGET('tpl.html').respond('');
@@ -55,7 +55,7 @@ describe('$templateRequest', function() {
expect(function() {
$rootScope.$digest();
$httpBackend.flush();
}).toThrowMinErr('$compile', 'tpload', 'Failed to load template: tpl.html');
}).not.toThrow();
}));
it('should keep track of how many requests are going on',

View File

@@ -56,7 +56,7 @@ describe('ngView', function() {
});
it('should not instantiate the associated controller when an empty template is downloaded', function() {
it('should instantiate the associated controller when an empty template is downloaded', function() {
var log = [], controllerScope,
Ctrl = function($scope) {
controllerScope = $scope;
@@ -73,9 +73,9 @@ describe('ngView', function() {
expect(function() {
$rootScope.$digest();
}).toThrowMinErr('$compile', 'tpload', 'Failed to load template: /tpl.html');
}).not.toThrow();
expect(controllerScope).toBeUndefined();
expect(controllerScope).toBeDefined();
});
});

View File

@@ -744,7 +744,7 @@ describe('$route', function() {
});
it('should throw an error when a template is empty or not found', function() {
it('should throw an error when a template is not found', function() {
module(function($routeProvider, $exceptionHandlerProvider) {
$exceptionHandlerProvider.mode('log');
$routeProvider.
@@ -766,7 +766,7 @@ describe('$route', function() {
$rootScope.$digest();
$httpBackend.flush();
expect($exceptionHandler.errors.pop().message).toContain("[$compile:tpload] Failed to load template: r2.html");
expect($exceptionHandler.errors.length).toBe(0);
$httpBackend.expectGET('r3.html').respond('abc');
$location.path('/r3');