amend(collectionRepeat): make sure it doesn't try to getComputedStyle of null

This commit is contained in:
Andrew
2015-03-02 14:11:12 -07:00
parent 72d39efd20
commit 873cded5c9

View File

@@ -18,7 +18,7 @@
*
* - The data given to collection-repeat must be an array.
* - If the `item-height` and `item-width` attributes are not supplied, it will be assumed that
* every item in the list's dimensions are the same as the first item's dimensions.
* every item in the list has the same dimensions as the first item.
* - Don't use angular one-time binding (`::`) with collection-repeat. The scope of each item is
* assigned new data and re-digested as you scroll. Bindings need to update, and one-time bindings
* won't.
@@ -437,9 +437,9 @@ function RepeatManagerFactory($rootScope, $window, $$rAF) {
// 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
// the first/last child's margins into height.
var style = getComputedStyle(afterItemsNode);
var firstStyle = getComputedStyle(afterItemsNode.firstElementChild);
var lastStyle = getComputedStyle(afterItemsNode.lastElementChild);
var style = getComputedStyle(afterItemsNode) || {};
var firstStyle = afterItemsNode.firstElementChild && getComputedStyle(afterItemsNode.firstElementChild) || {};
var lastStyle = afterItemsNode.lastElementChild && getComputedStyle(afterItemsNode.lastElementChild) || {};
repeaterAfterSize = (parseInt(style[isVertical ? 'height' : 'width']) || 0) +
(firstStyle && parseInt(firstStyle[isVertical ? 'marginTop' : 'marginLeft']) || 0) +
(lastStyle && parseInt(lastStyle[isVertical ? 'marginBottom' : 'marginRight']) || 0);