From 3c0c7165e26ec53bc408a6cca367e11f0433682a Mon Sep 17 00:00:00 2001 From: Ken Sheedlo Date: Thu, 1 Aug 2013 15:19:06 -0700 Subject: fix(docs): handle the empty string in errorDisplay --- docs/component-spec/errorDisplaySpec.js | 14 +++++++++++--- docs/src/templates/js/docs.js | 4 ++-- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'docs') diff --git a/docs/component-spec/errorDisplaySpec.js b/docs/component-spec/errorDisplaySpec.js index 8122e253..9549e220 100644 --- a/docs/component-spec/errorDisplaySpec.js +++ b/docs/component-spec/errorDisplaySpec.js @@ -7,7 +7,7 @@ describe("errorDisplay", function () { beforeEach(inject(function ($injector) { var $rootScope = $injector.get('$rootScope'), $compile = $injector.get('$compile'); - + $location = $injector.get('$location'); compileHTML = function (code) { @@ -35,7 +35,7 @@ describe("errorDisplay", function () { }); it('should interpolate a template with no parameters when search parameters are present', function () { - var elm; + var elm; spyOn($location, 'search').andReturn({ p0: 'foobaz' }); elm = compileHTML('
'); @@ -43,7 +43,7 @@ describe("errorDisplay", function () { }); it('should correctly interpolate search parameters', function () { - var elm; + var elm; spyOn($location, 'search').andReturn({ p0: '42' }); elm = compileHTML('
'); @@ -65,4 +65,12 @@ describe("errorDisplay", function () { elm = compileHTML('
'); expect(elm).toInterpolateTo('This Fooooo is {1} on {2}'); }); + + it('should correctly handle the empty string as an interpolation parameter', function () { + var elm; + + spyOn($location, 'search').andReturn({ p0: 'test', p1: '' }); + elm = compileHTML('
'); + expect(elm).toInterpolateTo('This test is a '); + }); }); \ No newline at end of file diff --git a/docs/src/templates/js/docs.js b/docs/src/templates/js/docs.js index f52c2216..309b4cd8 100644 --- a/docs/src/templates/js/docs.js +++ b/docs/src/templates/js/docs.js @@ -7,7 +7,7 @@ var docsApp = { docsApp.controller.DocsVersionsCtrl = ['$scope', '$window', 'NG_VERSIONS', function($scope, $window, NG_VERSIONS) { $scope.versions = expandVersions(NG_VERSIONS); $scope.version = ($scope.version || angular.version.full).match(/^([\d\.]+\d+)/)[1]; //match only the number - + $scope.jumpToDocsVersion = function(value) { var isLastStable, version, @@ -320,7 +320,7 @@ docsApp.directive.errorDisplay = ['$location', function ($location) { formatArgs = [attrs.errorDisplay], i; - for (i = 0; search['p'+i]; i++) { + for (i = 0; angular.isDefined(search['p'+i]); i++) { formatArgs.push(search['p'+i]); } element.text(interpolate.apply(null, formatArgs)); -- cgit v1.2.3