Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 3c0c716

Browse files
committed
fix(docs): handle the empty string in errorDisplay
1 parent 705c9d9 commit 3c0c716

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

docs/component-spec/errorDisplaySpec.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe("errorDisplay", function () {
77
beforeEach(inject(function ($injector) {
88
var $rootScope = $injector.get('$rootScope'),
99
$compile = $injector.get('$compile');
10-
10+
1111
$location = $injector.get('$location');
1212

1313
compileHTML = function (code) {
@@ -35,15 +35,15 @@ describe("errorDisplay", function () {
3535
});
3636

3737
it('should interpolate a template with no parameters when search parameters are present', function () {
38-
var elm;
38+
var elm;
3939

4040
spyOn($location, 'search').andReturn({ p0: 'foobaz' });
4141
elm = compileHTML('<div error-display="This is a test"></div>');
4242
expect(elm).toInterpolateTo('This is a test');
4343
});
4444

4545
it('should correctly interpolate search parameters', function () {
46-
var elm;
46+
var elm;
4747

4848
spyOn($location, 'search').andReturn({ p0: '42' });
4949
elm = compileHTML('<div error-display="The answer is {0}"></div>');
@@ -65,4 +65,12 @@ describe("errorDisplay", function () {
6565
elm = compileHTML('<div error-display="This {0} is {1} on {2}"></div>');
6666
expect(elm).toInterpolateTo('This Fooooo is {1} on {2}');
6767
});
68+
69+
it('should correctly handle the empty string as an interpolation parameter', function () {
70+
var elm;
71+
72+
spyOn($location, 'search').andReturn({ p0: 'test', p1: '' });
73+
elm = compileHTML('<div error-display="This {0} is a {1}"></div>');
74+
expect(elm).toInterpolateTo('This test is a ');
75+
});
6876
});

docs/src/templates/js/docs.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var docsApp = {
77
docsApp.controller.DocsVersionsCtrl = ['$scope', '$window', 'NG_VERSIONS', function($scope, $window, NG_VERSIONS) {
88
$scope.versions = expandVersions(NG_VERSIONS);
99
$scope.version = ($scope.version || angular.version.full).match(/^([\d\.]+\d+)/)[1]; //match only the number
10-
10+
1111
$scope.jumpToDocsVersion = function(value) {
1212
var isLastStable,
1313
version,
@@ -320,7 +320,7 @@ docsApp.directive.errorDisplay = ['$location', function ($location) {
320320
formatArgs = [attrs.errorDisplay],
321321
i;
322322

323-
for (i = 0; search['p'+i]; i++) {
323+
for (i = 0; angular.isDefined(search['p'+i]); i++) {
324324
formatArgs.push(search['p'+i]);
325325
}
326326
element.text(interpolate.apply(null, formatArgs));

0 commit comments

Comments
 (0)