}
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;
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" ) );
}
}
dfn8099.remove();
});
-test( "show() resolves correct default display, detached nodes (#10006)", function(){
- // Tests originally contributed by Orkel in
- // https://github.com/jquery/jquery/pull/458
- expect( 11 );
+test( "show() resolves correct default display for detached nodes", function(){
+ expect( 13 );
- var div, span;
+ var div, span, tr, trDisplay;
div = jQuery("<div class='hidden'>");
div.show().appendTo("#qunit-fixture");
div.show().appendTo("#qunit-fixture");
equal( div.css("display"), "inline", "Make sure that element has same display when it was created." );
div.remove();
+
+ tr = jQuery("<tr/>");
+ jQuery("#table").append( tr );
+ trDisplay = tr.css( "display" );
+ tr.detach().hide().show();
+
+ equal( tr[ 0 ].style.display, trDisplay, "For detached tr elements, display should always be like for attached trs" );
+ tr.remove();
+
+ span = span = jQuery("<span/>").hide().show();
+ equal( span[ 0 ].style.display, "inline", "For detached span elements, display should always be inline" );
+ span.remove();
});
test("show() resolves correct default display #10227", function() {