Skip to content

Commit

Permalink
amend(collectionRepeat): make sure it doesn't try to getComputedStyle…
Browse files Browse the repository at this point in the history
… of null
  • Loading branch information
ajoslin committed Mar 2, 2015
1 parent 72d39ef commit 873cded
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions js/angular/directive/collectionRepeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 873cded

Please sign in to comment.