Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
CSS: jQuery#hide should always save display value
Fixes #14750
Closes gh-1509
  • Loading branch information
markelog authored and dmethvin committed Mar 21, 2014
1 parent 85af4e6 commit 5a8f769
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/css.js
Expand Up @@ -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" ) );
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions test/unit/css.js
Expand Up @@ -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,
Expand Down

0 comments on commit 5a8f769

Please sign in to comment.