diff options
author | Colin Snover <github.com@zetafleet.com> | 2010-10-05 13:23:10 -0500 |
---|---|---|
committer | Colin Snover <github.com@zetafleet.com> | 2010-10-05 13:23:10 -0500 |
commit | 0229b83f7e5bf64edb2888ab349bedcd1a45e7c1 (patch) | |
tree | b64ed6838516be56965ddf9b0bbf9deb2437772a /src | |
parent | 57c046f91cbc3caf174ecc993fe883c027340901 (diff) | |
download | jquery-0229b83f7e5bf64edb2888ab349bedcd1a45e7c1.tar.gz jquery-0229b83f7e5bf64edb2888ab349bedcd1a45e7c1.zip |
Fix :visible does not work properly when display:none is set directly on an element in IE8. Fixes #4512.
Diffstat (limited to 'src')
-rw-r--r-- | src/css.js | 11 | ||||
-rw-r--r-- | src/support.js | 15 |
2 files changed, 17 insertions, 9 deletions
diff --git a/src/css.js b/src/css.js index 4bf818e5a..8751860a8 100644 --- a/src/css.js +++ b/src/css.js @@ -280,14 +280,9 @@ function getWH( elem, name, extra ) { if ( jQuery.expr && jQuery.expr.filters ) { jQuery.expr.filters.hidden = function( elem ) { - var width = elem.offsetWidth, height = elem.offsetHeight, - skip = elem.nodeName.toLowerCase() === "tr"; - - return width === 0 && height === 0 && !skip ? - true : - width > 0 && height > 0 && !skip ? - false : - (elem.style.display || jQuery.css( elem, "display" )) === "none"; + var width = elem.offsetWidth, height = elem.offsetHeight; + + return (width === 0 && height === 0) || (!jQuery.support.reliableHiddenOffsets && (elem.style.display || jQuery.css( elem, "display" )) === "none"); }; jQuery.expr.filters.visible = function( elem ) { diff --git a/src/support.js b/src/support.js index d35dbed2d..299fbd277 100644 --- a/src/support.js +++ b/src/support.js @@ -65,7 +65,8 @@ checkClone: false, scriptEval: false, noCloneEvent: true, - boxModel: null + boxModel: null, + reliableHiddenOffsets: true }; // Make sure that the options inside disabled selects aren't marked as disabled @@ -117,6 +118,18 @@ document.body.appendChild( div ); jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2; + + // Check if table cells still have offsetWidth/Height when they are set + // to display:none and there are still other visible table cells in a + // table row; if so, offsetWidth/Height are not reliable for use when + // determining if an element has been hidden directly using + // display:none (it is still safe to use offsets if a parent element is + // hidden; don safety goggles and see bug #4512 for more information). + // (only IE 8 fails this test) + div.innerHTML = '<table><tr><td style="display:none"></td><td>t</td></tr></table>'; + jQuery.support.reliableHiddenOffsets = div.getElementsByTagName('td')[0].offsetHeight === 0; + div.innerHTML = ''; + document.body.removeChild( div ).style.display = 'none'; div = null; }); |