Skip to content

Commit

Permalink
fixed IE8 NaN bug when parsing 'auto' properties
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Apr 15, 2014
1 parent 18a6fa1 commit 702eea6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions jquery.matchHeight.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@

// handle padding and border correctly (required when not using border-box)
if ($that.css('box-sizing') !== 'border-box') {
verticalPadding += parseInt($that.css('border-top-width'), 10) + parseInt($that.css('border-bottom-width'), 10);
verticalPadding += parseInt($that.css('padding-top'), 10) + parseInt($that.css('padding-bottom'), 10);
verticalPadding += _parse($that.css('border-top-width')) + _parse($that.css('border-bottom-width'));
verticalPadding += _parse($that.css('padding-top')) + _parse($that.css('padding-bottom'));
}

// set the height (accounting for padding and border)
Expand Down Expand Up @@ -153,7 +153,7 @@
// group elements by their top position
$elements.each(function(){
var $that = $(this),
top = $that.offset().top - parseInt($that.css('margin-top'), 10),
top = $that.offset().top - _parse($that.css('margin-top')),
lastRow = rows.length > 0 ? rows[rows.length - 1] : null;

if (lastRow === null) {
Expand All @@ -176,4 +176,9 @@
return rows;
};

})(jQuery);
var _parse = function(value) {
// parse value and convert NaN to 0
return parseFloat(value) || 0;
};

})(jQuery);

0 comments on commit 702eea6

Please sign in to comment.