CSS: fix visible/hidden for IE6/7

This commit is contained in:
Timmy Willison 2016-01-05 20:10:06 -05:00
parent 9e2f55f47c
commit ecf52b948b
2 changed files with 24 additions and 5 deletions

View File

@ -5,14 +5,32 @@ define( [
"../css"
], function( jQuery, support ) {
function getDisplay( elem ) {
return elem.style && elem.style.display || jQuery.css( elem, "display" );
}
function filterHidden( elem ) {
while ( elem && elem.nodeType === 1 ) {
if ( getDisplay( elem ) === "none" || elem.type === "hidden" ) {
return true;
}
elem = elem.parentNode;
}
return false;
}
jQuery.expr.filters.hidden = function( elem ) {
return !jQuery.expr.filters.visible( elem );
// Support: Opera <= 12.12
// Opera reports offsetWidths and offsetHeights less than zero on some elements
return support.reliableHiddenOffsets() ?
( elem.offsetWidth <= 0 && elem.offsetHeight <= 0 &&
!elem.getClientRects().length ) :
filterHidden( elem );
};
jQuery.expr.filters.visible = function( elem ) {
return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length ) &&
( support.reliableHiddenOffsets() ||
( ( elem.style && elem.style.display ) || jQuery.css( elem, "display" ) ) !== "none" );
return !jQuery.expr.filters.hidden( elem );
};
} );

View File

@ -159,7 +159,8 @@ define( [
div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
contents = div.getElementsByTagName( "td" );
contents[ 0 ].style.cssText = "margin:0;border:0;padding:0;display:none";
reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0;
reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0 &&
contents[ 0 ].getClientRects().length === 0;
if ( reliableHiddenOffsetsVal ) {
contents[ 0 ].style.display = "";
contents[ 1 ].style.display = "none";