Skip to content

Commit bd4723c

Browse files
committed
fix(collectionRepeat): when array is empty, dont use heightGetter/widthGetter
Closes #3440.
1 parent eb2ed81 commit bd4723c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Diff for: js/angular/directive/collectionRepeat.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,14 @@ function RepeatManagerFactory($rootScope, $window, $$rAF) {
496496
var isLayoutReady = false;
497497
var isDataReady = false;
498498
this.refreshLayout = function(itemsAfterRepeater) {
499-
estimatedHeight = heightGetter(0, data[0]);
500-
estimatedWidth = widthGetter(0, data[0]);
499+
if (data.length) {
500+
estimatedHeight = heightGetter(0, data[0]);
501+
estimatedWidth = widthGetter(0, data[0]);
502+
} else {
503+
// If we don't have any data in our array, just guess.
504+
estimatedHeight = 100;
505+
estimatedWidth = 100;
506+
}
501507

502508
// Get the size of every element AFTER the repeater. We have to get the margin before and
503509
// after the first/last element to fix a browser bug with getComputedStyle() not counting

0 commit comments

Comments
 (0)