Skip to content

Commit 4917d6c

Browse files
committed
preserve inline styles on hidden parents, closes #46
1 parent b4326d3 commit 4917d6c

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

jquery.matchHeight.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,16 @@
149149
var scrollTop = $(window).scrollTop(),
150150
htmlHeight = $('html').outerHeight(true);
151151

152-
// temporarily must force hidden parents visible
152+
// get hidden parents
153153
var $hiddenParents = $elements.parents().filter(':hidden');
154+
155+
// cache the original inline style
156+
$hiddenParents.each(function() {
157+
var $that = $(this);
158+
$that.data('style-cache', $that.attr('style'));
159+
});
160+
161+
// temporarily must force hidden parents visible
154162
$hiddenParents.css('display', 'block');
155163

156164
// get rows if using byRow, otherwise assume one row
@@ -229,7 +237,10 @@
229237
});
230238

231239
// revert hidden parents
232-
$hiddenParents.css('display', '');
240+
$hiddenParents.each(function() {
241+
var $that = $(this);
242+
$that.attr('style', $that.data('style-cache') || null);
243+
});
233244

234245
// restore scroll position if enabled
235246
if (matchHeight._maintainScroll)

0 commit comments

Comments
 (0)