From 873cded5c9627bd4cca18e7195155c8bb1c59961 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 2 Mar 2015 14:11:12 -0700 Subject: [PATCH] amend(collectionRepeat): make sure it doesn't try to getComputedStyle of null --- js/angular/directive/collectionRepeat.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/angular/directive/collectionRepeat.js b/js/angular/directive/collectionRepeat.js index 5875206c54..9898a259a4 100644 --- a/js/angular/directive/collectionRepeat.js +++ b/js/angular/directive/collectionRepeat.js @@ -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);