diff options
author | Oleg Gaidarenko <markelog@gmail.com> | 2014-02-05 09:54:15 +0400 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2014-03-20 22:47:35 -0400 |
commit | 6dcca6da362a517e6bbcf0b093797b3341b6e69d (patch) | |
tree | 392615f86105221da6f20b02f850f3d5115326ff | |
parent | 9ec429cf6270e455aba4eba85f4db80e633806b6 (diff) | |
download | jquery-6dcca6da362a517e6bbcf0b093797b3341b6e69d.tar.gz jquery-6dcca6da362a517e6bbcf0b093797b3341b6e69d.zip |
CSS: jQuery#hide should always save display value
Fixes #14750
Closes gh-1509
(cherry picked from commit 5a8f76933288396b915800a18240aa17d3414201)
Conflicts:
src/css.js
-rw-r--r-- | src/css.js | 9 | ||||
-rw-r--r-- | test/unit/css.js | 10 |
2 files changed, 13 insertions, 6 deletions
diff --git a/src/css.js b/src/css.js index 1e454caf1..31f551eb1 100644 --- a/src/css.js +++ b/src/css.js @@ -92,13 +92,10 @@ function showHide( elements, show ) { values[ index ] = jQuery._data( elem, "olddisplay", defaultDisplay(elem.nodeName) ); } } else { + hidden = isHidden( elem ); - if ( !values[ index ] ) { - hidden = isHidden( elem ); - - if ( display && display !== "none" || !hidden ) { - jQuery._data( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) ); - } + if ( display && display !== "none" || !hidden ) { + jQuery._data( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) ); } } } diff --git a/test/unit/css.js b/test/unit/css.js index 018bfc942..c949ae062 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -1106,6 +1106,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, |