mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Effects: Don't overwrite display:none when .hide()ing hidden elements
Fixes #14848 Closes gh-1548
This commit is contained in:
parent
5a8f769332
commit
890d441aa5
15
src/effects.js
vendored
15
src/effects.js
vendored
@ -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" );
|
||||
// Get default display if display is currently "none"
|
||||
if ( display === "none" ) {
|
||||
display = defaultDisplay( elem.nodeName );
|
||||
}
|
||||
if ( display === "inline" &&
|
||||
// Test default display if display is currently "none"
|
||||
if ( (display === "none" ? defaultDisplay( elem.nodeName ) : display) === "inline" &&
|
||||
jQuery.css( elem, "float" ) === "none" ) {
|
||||
|
||||
style.display = "inline-block";
|
||||
@ -196,6 +193,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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -238,6 +239,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
13
test/unit/effects.js
vendored
13
test/unit/effects.js
vendored
@ -1620,6 +1620,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().addBack(),
|
||||
step = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user