mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-10 22:44:01 +08:00
fix(templateRequest): allow empty html template
allow empty html template and not throw error Closes #9581
This commit is contained in:
committed by
Vojta Jina
parent
38d12de661
commit
52ceec2229
@@ -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;
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user