mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
amend(collectionRepeat): make sure it doesn't try to getComputedStyle of null
This commit is contained in:
8
js/angular/directive/collectionRepeat.js
vendored
8
js/angular/directive/collectionRepeat.js
vendored
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user