aboutsummaryrefslogtreecommitdiffstats
path: root/src/css.js
diff options
context:
space:
mode:
authorOleg <markelog@gmail.com>2012-09-29 00:56:49 +0400
committerDave Methvin <dave.methvin@gmail.com>2012-10-28 23:32:54 -0400
commitbea5ecbba72f22e8924186d9b81839122ec86aef (patch)
treed2a84f93922a58ec1a390c18a1349fe49fefd86b /src/css.js
parent5be4c10cf78c0ec6785217a8a4ea10eacaedeb1c (diff)
downloadjquery-bea5ecbba72f22e8924186d9b81839122ec86aef.tar.gz
jquery-bea5ecbba72f22e8924186d9b81839122ec86aef.zip
Fix #10416. Don't trust computed styles on detached elements. Close gh-941.
Diffstat (limited to 'src/css.js')
-rw-r--r--src/css.js14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/css.js b/src/css.js
index ad42a048a..6dd13efdf 100644
--- a/src/css.js
+++ b/src/css.js
@@ -44,12 +44,14 @@ function vendorPropName( style, name ) {
}
function isHidden( elem, el ) {
+ // isHidden might be called from jQuery#filter function;
+ // in that case, element will be second argument
elem = el || elem;
- return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
+ return curCSS( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
}
function showHide( elements, show ) {
- var elem, display,
+ var elem,
values = [],
index = 0,
length = elements.length;
@@ -73,12 +75,8 @@ function showHide( elements, show ) {
if ( elem.style.display === "" && isHidden( elem ) ) {
values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) );
}
- } else {
- display = curCSS( elem, "display" );
-
- if ( !values[ index ] && display !== "none" ) {
- jQuery._data( elem, "olddisplay", display );
- }
+ } else if ( !values[ index ] && !isHidden( elem ) ) {
+ jQuery._data( elem, "olddisplay", curCSS( elem, "display" ) );
}
}