Skip to content

Commit

Permalink
preserve inline styles on hidden parents, closes #46
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Jan 12, 2015
1 parent b4326d3 commit 4917d6c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions jquery.matchHeight.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,16 @@
var scrollTop = $(window).scrollTop(),
htmlHeight = $('html').outerHeight(true);

// temporarily must force hidden parents visible
// get hidden parents
var $hiddenParents = $elements.parents().filter(':hidden');

// cache the original inline style
$hiddenParents.each(function() {
var $that = $(this);
$that.data('style-cache', $that.attr('style'));
});

// temporarily must force hidden parents visible
$hiddenParents.css('display', 'block');

// get rows if using byRow, otherwise assume one row
Expand Down Expand Up @@ -229,7 +237,10 @@
});

// revert hidden parents
$hiddenParents.css('display', '');
$hiddenParents.each(function() {
var $that = $(this);
$that.attr('style', $that.data('style-cache') || null);
});

// restore scroll position if enabled
if (matchHeight._maintainScroll)
Expand Down

0 comments on commit 4917d6c

Please sign in to comment.