Skip to content

Commit 873cded

Browse files
committed
amend(collectionRepeat): make sure it doesn't try to getComputedStyle of null
1 parent 72d39ef commit 873cded

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

js/angular/directive/collectionRepeat.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
* - The data given to collection-repeat must be an array.
2020
* - If the `item-height` and `item-width` attributes are not supplied, it will be assumed that
21-
* every item in the list's dimensions are the same as the first item's dimensions.
21+
* every item in the list has the same dimensions as the first item.
2222
* - Don't use angular one-time binding (`::`) with collection-repeat. The scope of each item is
2323
* assigned new data and re-digested as you scroll. Bindings need to update, and one-time bindings
2424
* won't.
@@ -437,9 +437,9 @@ function RepeatManagerFactory($rootScope, $window, $$rAF) {
437437
// Get the size of every element AFTER the repeater. We have to get the margin before and
438438
// after the first/last element to fix a browser bug with getComputedStyle() not counting
439439
// the first/last child's margins into height.
440-
var style = getComputedStyle(afterItemsNode);
441-
var firstStyle = getComputedStyle(afterItemsNode.firstElementChild);
442-
var lastStyle = getComputedStyle(afterItemsNode.lastElementChild);
440+
var style = getComputedStyle(afterItemsNode) || {};
441+
var firstStyle = afterItemsNode.firstElementChild && getComputedStyle(afterItemsNode.firstElementChild) || {};
442+
var lastStyle = afterItemsNode.lastElementChild && getComputedStyle(afterItemsNode.lastElementChild) || {};
443443
repeaterAfterSize = (parseInt(style[isVertical ? 'height' : 'width']) || 0) +
444444
(firstStyle && parseInt(firstStyle[isVertical ? 'marginTop' : 'marginLeft']) || 0) +
445445
(lastStyle && parseInt(lastStyle[isVertical ? 'marginBottom' : 'marginRight']) || 0);

0 commit comments

Comments
 (0)