diff --git a/src/ng/filter/limitTo.js b/src/ng/filter/limitTo.js index 7e198cb33110..4f87b9964159 100644 --- a/src/ng/filter/limitTo.js +++ b/src/ng/filter/limitTo.js @@ -73,7 +73,11 @@ function limitToFilter(){ return function(input, limit) { if (!isArray(input) && !isString(input)) return input; - limit = int(limit); + if (Math.abs(Number(limit)) === Infinity) { + limit = Number(limit); + } else { + limit = int(limit); + } if (isString(input)) { //NaN check on limit diff --git a/test/ng/filter/limitToSpec.js b/test/ng/filter/limitToSpec.js index 2ebdc21480fb..f938a28ae23e 100644 --- a/test/ng/filter/limitToSpec.js +++ b/test/ng/filter/limitToSpec.js @@ -68,4 +68,18 @@ describe('Filter: limitTo', function() { expect(limitTo(str, -9)).toEqual(str); expect(limitTo(str, '-9')).toEqual(str); }) + + it('should return entire input array when limited by Infinity', function() { + expect(limitTo(items, Infinity)).toEqual(items); + expect(limitTo(items, 'Infinity')).toEqual(items); + expect(limitTo(items, -Infinity)).toEqual(items); + expect(limitTo(items, '-Infinity')).toEqual(items); + }); + + it('should return the entire string when limited by Infinity', function() { + expect(limitTo(str, Infinity)).toEqual(str); + expect(limitTo(str, 'Infinity')).toEqual(str); + expect(limitTo(str, -Infinity)).toEqual(str); + expect(limitTo(str, '-Infinity')).toEqual(str); + }); });