aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Gibson <richard.gibson@gmail.com>2014-03-20 03:39:36 -0400
committerDave Methvin <dave.methvin@gmail.com>2014-03-20 23:01:39 -0400
commit80cf965e02e71dc1b11bf8c1b3d216b9ab4e99ac (patch)
tree91e9fa57832ee5062a5aab2ec9ada5c5aadb664e
parent6dcca6da362a517e6bbcf0b093797b3341b6e69d (diff)
downloadjquery-80cf965e02e71dc1b11bf8c1b3d216b9ab4e99ac.tar.gz
jquery-80cf965e02e71dc1b11bf8c1b3d216b9ab4e99ac.zip
Effects: Don't overwrite display:none when .hide()ing hidden elements
Fixes #14848 Closes gh-1548 (cherry picked from commit 890d441aa5d319e49951ba6f0ec719cd4cb96759) Conflicts: src/effects.js
-rw-r--r--src/effects.js15
-rw-r--r--test/unit/effects.js13
2 files changed, 23 insertions, 5 deletions
diff --git a/src/effects.js b/src/effects.js
index c843549c2..f6b6dbd77 100644
--- a/src/effects.js
+++ b/src/effects.js
@@ -160,11 +160,8 @@ function defaultPrefilter( elem, props, opts ) {
// Set display property to inline-block for height/width
// animations on inline elements that are having width/height animated
display = jQuery.css( elem, "display" );
- dDisplay = defaultDisplay( elem.nodeName );
- if ( display === "none" ) {
- display = dDisplay;
- }
- if ( display === "inline" &&
+ // Test default display if display is currently "none"
+ if ( (display === "none" ? defaultDisplay( elem.nodeName ) : display) === "inline" &&
jQuery.css( elem, "float" ) === "none" ) {
// inline-level elements accept inline-block;
@@ -204,6 +201,10 @@ function defaultPrefilter( elem, props, opts ) {
}
}
orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
+
+ // Any non-fx value stops us from restoring the original display value
+ } else {
+ display = undefined;
}
}
@@ -245,6 +246,10 @@ function defaultPrefilter( elem, props, opts ) {
}
}
}
+
+ // If this is a noop like .hide().hide(), restore an overwritten display value
+ } else if ( (display === "none" ? defaultDisplay( elem.nodeName ) : display) === "inline" ) {
+ style.display = display;
}
}
diff --git a/test/unit/effects.js b/test/unit/effects.js
index ca0754083..a27851459 100644
--- a/test/unit/effects.js
+++ b/test/unit/effects.js
@@ -1672,6 +1672,19 @@ test( "hide, fadeOut and slideUp called on element width height and width = 0 sh
this.clock.tick( 400 );
});
+test( "hide should not leave hidden inline elements visible (#14848)", 2, function() {
+ var el = jQuery("#simon1");
+
+ el.hide( 1, function() {
+ equal( el.css( "display" ), "none", "hidden" );
+ el.hide( 1, function() {
+ equal( el.css( "display" ), "none", "still hidden" );
+ });
+ });
+
+ this.clock.tick( 100 );
+});
+
test( "Handle queue:false promises", 10, function() {
var foo = jQuery( "#foo" ).clone().andSelf(),
step = 1;