aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Gaidarenko <markelog@gmail.com>2014-02-05 09:54:15 +0400
committerDave Methvin <dave.methvin@gmail.com>2014-03-20 22:37:05 -0400
commit5a8f76933288396b915800a18240aa17d3414201 (patch)
tree007995562368bab40c32ecdfa424edb75882ce6e
parent85af4e6412e49c2e6a872feef00718a46c2fa2ce (diff)
downloadjquery-5a8f76933288396b915800a18240aa17d3414201.tar.gz
jquery-5a8f76933288396b915800a18240aa17d3414201.zip
CSS: jQuery#hide should always save display value
Fixes #14750 Closes gh-1509
-rw-r--r--src/css.js9
-rw-r--r--test/unit/css.js10
2 files changed, 13 insertions, 6 deletions
diff --git a/src/css.js b/src/css.js
index 2a3a84d00..a7f61bb1e 100644
--- a/src/css.js
+++ b/src/css.js
@@ -177,13 +177,10 @@ function showHide( elements, show ) {
values[ index ] = data_priv.access( elem, "olddisplay", defaultDisplay(elem.nodeName) );
}
} else {
+ hidden = isHidden( elem );
- if ( !values[ index ] ) {
- hidden = isHidden( elem );
-
- if ( display && display !== "none" || !hidden ) {
- data_priv.set( elem, "olddisplay", hidden ? display : jQuery.css(elem, "display") );
- }
+ if ( display !== "none" || !hidden ) {
+ data_priv.set( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) );
}
}
}
diff --git a/test/unit/css.js b/test/unit/css.js
index 4ac545244..6a8d7ac46 100644
--- a/test/unit/css.js
+++ b/test/unit/css.js
@@ -1048,6 +1048,16 @@ asyncTest( "Make sure initialized display value for disconnected nodes is correc
jQuery._removeData( jQuery("#display")[ 0 ] );
});
+test( "show() after hide() should always set display to initial value (#14750)", 1, function() {
+ var div = jQuery( "<div />" ),
+ fixture = jQuery( "#qunit-fixture" );
+
+ fixture.append( div );
+
+ div.css( "display", "inline" ).hide().show().css( "display", "list-item" ).hide().show();
+ equal( div.css( "display" ), "list-item", "should get last set display value" );
+});
+
// Support: IE < 11, Safari < 7
// We have to jump through the hoops here in order to test work with "order" CSS property,
// that some browsers do not support. This test is not, strictly speaking, correct,