From bd4723c98d6dde37d2715c655c7d2c9d02d71709 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 14 Apr 2015 10:28:54 -0600 Subject: [PATCH] fix(collectionRepeat): when array is empty, dont use heightGetter/widthGetter Closes #3440. --- js/angular/directive/collectionRepeat.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/js/angular/directive/collectionRepeat.js b/js/angular/directive/collectionRepeat.js index 0ac024c7f3a..719bb30d9b2 100644 --- a/js/angular/directive/collectionRepeat.js +++ b/js/angular/directive/collectionRepeat.js @@ -496,8 +496,14 @@ function RepeatManagerFactory($rootScope, $window, $$rAF) { var isLayoutReady = false; var isDataReady = false; this.refreshLayout = function(itemsAfterRepeater) { - estimatedHeight = heightGetter(0, data[0]); - estimatedWidth = widthGetter(0, data[0]); + if (data.length) { + estimatedHeight = heightGetter(0, data[0]); + estimatedWidth = widthGetter(0, data[0]); + } else { + // If we don't have any data in our array, just guess. + estimatedHeight = 100; + estimatedWidth = 100; + } // Get the size of every element AFTER the repeater. We have to get the margin before and // after the first/last element to fix a browser bug with getComputedStyle() not counting