aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTimmy Willison <timmywillisn@gmail.com>2016-01-05 20:10:06 -0500
committerTimmy Willison <timmywillisn@gmail.com>2016-01-06 14:05:17 -0500
commitecf52b948bcc7c9a28b5b2f93a0764868f09428e (patch)
tree7f5c28ba75206b8eeb775ade191373d9ed57baa5 /src
parent9e2f55f47ccc055aafa07d131030ff85e2caa39e (diff)
downloadjquery-ecf52b948bcc7c9a28b5b2f93a0764868f09428e.tar.gz
jquery-ecf52b948bcc7c9a28b5b2f93a0764868f09428e.zip
CSS: fix visible/hidden for IE6/7
Diffstat (limited to 'src')
-rw-r--r--src/css/hiddenVisibleSelectors.js26
-rw-r--r--src/css/support.js3
2 files changed, 24 insertions, 5 deletions
diff --git a/src/css/hiddenVisibleSelectors.js b/src/css/hiddenVisibleSelectors.js
index 46c2cb827..899b9eca4 100644
--- a/src/css/hiddenVisibleSelectors.js
+++ b/src/css/hiddenVisibleSelectors.js
@@ -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 );
};
} );
diff --git a/src/css/support.js b/src/css/support.js
index 97d6d4aa1..6ff4cb19f 100644
--- a/src/css/support.js
+++ b/src/css/support.js
@@ -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";