diff options
author | Oleg Gaidarenko <markelog@gmail.com> | 2014-04-26 21:24:05 +0400 |
---|---|---|
committer | Oleg Gaidarenko <markelog@gmail.com> | 2014-04-30 17:14:22 +0400 |
commit | f833c9af573462cdec5637db8e58015b288a0a7e (patch) | |
tree | e39bb24c58f3ef1e695dc420f597fe08a76cee24 | |
parent | 874304fc30743951a7eaf06ea1e2275e507752ee (diff) | |
download | jquery-f833c9af573462cdec5637db8e58015b288a0a7e.tar.gz jquery-f833c9af573462cdec5637db8e58015b288a0a7e.zip |
Effects: Respect display value on inline elements
Take "olddisplay" value into the account
Fixes #14824
Closes gh-1566
Ref 73fe17299a840a8a7f3ffffcac15e32a88bd3d66
(cherry-picked from c34dbf5a8d135e0f873ab7a76d1c8f8e316f31e4)
Conflicts:
src/effects.js
-rw-r--r-- | src/effects.js | 9 | ||||
-rw-r--r-- | test/data/testsuite.css | 3 | ||||
-rw-r--r-- | test/unit/effects.js | 24 |
3 files changed, 33 insertions, 3 deletions
diff --git a/src/effects.js b/src/effects.js index 223c8e549..0469eefb6 100644 --- a/src/effects.js +++ b/src/effects.js @@ -116,7 +116,7 @@ function createTween( value, prop, animation ) { function defaultPrefilter( elem, props, opts ) { /* jshint validthis: true */ - var prop, value, toggle, tween, hooks, oldfire, display, + var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay, anim = this, orig = {}, style = elem.style, @@ -160,9 +160,12 @@ 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" ); + // Test default display if display is currently "none" - if ( (display === "none" ? defaultDisplay( elem.nodeName ) : display) === "inline" && - jQuery.css( elem, "float" ) === "none" ) { + checkDisplay = display === "none" ? + jQuery._data( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display; + + if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) { // inline-level elements accept inline-block; // block-level elements need to be inline with layout diff --git a/test/data/testsuite.css b/test/data/testsuite.css index 134993c01..545d8ce5d 100644 --- a/test/data/testsuite.css +++ b/test/data/testsuite.css @@ -152,4 +152,7 @@ section { background:#f0f; display:block; } /* #11971 */ #foo { background: url(1x1.jpg) right bottom no-repeat; } +/* #14824 */ +#span-14824 { display: block; } + #display { display: list-item !important; } diff --git a/test/unit/effects.js b/test/unit/effects.js index a27851459..e857b229b 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -2214,4 +2214,28 @@ test( "slideDown() after stop() (#13483)", 2, function() { 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 ); +}); + })(); |