Commit f833c9af authored by Oleg Gaidarenko's avatar Oleg Gaidarenko

Effects: Respect display value on inline elements

Take "olddisplay" value into the account

Fixes #14824
Closes gh-1566
Ref 73fe1729

(cherry-picked from c34dbf5a)
Conflicts:
	src/effects.js
parent 874304fc
...@@ -116,7 +116,7 @@ function createTween( value, prop, animation ) { ...@@ -116,7 +116,7 @@ function createTween( value, prop, animation ) {
function defaultPrefilter( elem, props, opts ) { function defaultPrefilter( elem, props, opts ) {
/* jshint validthis: true */ /* jshint validthis: true */
var prop, value, toggle, tween, hooks, oldfire, display, var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay,
anim = this, anim = this,
orig = {}, orig = {},
style = elem.style, style = elem.style,
...@@ -160,9 +160,12 @@ function defaultPrefilter( elem, props, opts ) { ...@@ -160,9 +160,12 @@ function defaultPrefilter( elem, props, opts ) {
// Set display property to inline-block for height/width // Set display property to inline-block for height/width
// animations on inline elements that are having width/height animated // animations on inline elements that are having width/height animated
display = jQuery.css( elem, "display" ); display = jQuery.css( elem, "display" );
// Test default display if display is currently "none" // Test default display if display is currently "none"
if ( (display === "none" ? defaultDisplay( elem.nodeName ) : display) === "inline" && checkDisplay = display === "none" ?
jQuery.css( elem, "float" ) === "none" ) { jQuery._data( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;
if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {
// inline-level elements accept inline-block; // inline-level elements accept inline-block;
// block-level elements need to be inline with layout // block-level elements need to be inline with layout
......
...@@ -152,4 +152,7 @@ section { background:#f0f; display:block; } ...@@ -152,4 +152,7 @@ section { background:#f0f; display:block; }
/* #11971 */ /* #11971 */
#foo { background: url(1x1.jpg) right bottom no-repeat; } #foo { background: url(1x1.jpg) right bottom no-repeat; }
/* #14824 */
#span-14824 { display: block; }
#display { display: list-item !important; } #display { display: list-item !important; }
...@@ -2214,4 +2214,28 @@ test( "slideDown() after stop() (#13483)", 2, function() { ...@@ -2214,4 +2214,28 @@ test( "slideDown() after stop() (#13483)", 2, function() {
clock.tick( 10 ); clock.tick( 10 );
}); });
test( "Respect display value on inline elements (#14824)", 2, function() {
var clock = this.clock,
fromStyleSheet = jQuery( "<span id='span-14824' />" ),
fromStyleAttr = jQuery( "<span style='display: block;' />" );
jQuery( "#qunit-fixture" ).append( fromStyleSheet, fromStyleAttr );
fromStyleSheet.slideUp(function() {
jQuery( this ).slideDown( function() {
equal( jQuery( this ).css( "display" ), "block",
"Respect previous display value (from stylesheet) on span element" );
});
});
fromStyleAttr.slideUp( function() {
jQuery( this ).slideDown( function() {
equal( jQuery( this ).css( "display" ), "block",
"Respect previous display value (from style attribute) on span element" );
});
});
clock.tick( 800 );
});
})(); })();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment