From a49e577db8890d2eadb40d79533b30f82f7c5f52 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 1 Dec 2014 10:58:17 -0700 Subject: [PATCH] fix(collectionRepeat): parse collection-item-height/width to int Closes #2633. --- js/angular/directive/collectionRepeat.js | 8 ++++---- test/unit/angular/directive/collectionRepeat.unit.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/js/angular/directive/collectionRepeat.js b/js/angular/directive/collectionRepeat.js index 28a0ece7e0..001aa6c416 100644 --- a/js/angular/directive/collectionRepeat.js +++ b/js/angular/directive/collectionRepeat.js @@ -170,16 +170,16 @@ function($collectionRepeatManager, $collectionDataSource, $parse) { var heightGetter = function(scope, locals) { var result = heightParsed(scope, locals); if (isString(result) && result.indexOf('%') > -1) { - return Math.floor(parseInt(result, 10) / 100 * scrollView.__clientHeight); + return Math.floor(parseInt(result) / 100 * scrollView.__clientHeight); } - return result; + return parseInt(result); }; var widthGetter = function(scope, locals) { var result = widthParsed(scope, locals); if (isString(result) && result.indexOf('%') > -1) { - return Math.floor(parseInt(result, 10) / 100 * scrollView.__clientWidth); + return Math.floor(parseInt(result) / 100 * scrollView.__clientWidth); } - return result; + return parseInt(result); }; var match = $attr.collectionRepeat.match(/^\s*([\s\S]+?)\s+in\s+([\s\S]+?)(?:\s+track\s+by\s+([\s\S]+?))?\s*$/); diff --git a/test/unit/angular/directive/collectionRepeat.unit.js b/test/unit/angular/directive/collectionRepeat.unit.js index 41882f3774..b99dfc5565 100644 --- a/test/unit/angular/directive/collectionRepeat.unit.js +++ b/test/unit/angular/directive/collectionRepeat.unit.js @@ -71,8 +71,8 @@ describe('collectionRepeat directive', function() { }); describe('widthGetter & heightGetter', function() { - it('should work with given amounts', function() { - var el = setup('collection-repeat="a in b" collection-item-height="5" collection-item-width="10"'); + it('should work with given amounts parsed to int', function() { + var el = setup('collection-repeat="a in b" collection-item-height="\'5\'" collection-item-width="\'10\'"'); expect(dataSource.options.heightGetter()).toBe(5); expect(dataSource.options.widthGetter()).toBe(10); });