fix(collectionRepeat): parse collection-item-height/width to int

Closes #2633.
This commit is contained in:
Andrew
2014-12-01 10:58:17 -07:00
parent 037d2c368e
commit a49e577db8
2 changed files with 6 additions and 6 deletions

View File

@@ -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*$/);

View File

@@ -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);
});