diff --git a/src/effects.js b/src/effects.js index 51ce0c57..bac2e1d5 100644 --- a/src/effects.js +++ b/src/effects.js @@ -61,10 +61,10 @@ jQuery.fn.extend({ } else { for ( var i = 0, j = this.length; i < j; i++ ) { var display = jQuery.css( this[i], "display" ); - - if ( display !== "none" ) { - jQuery.data( this[i], "olddisplay", display ); - } + + if ( !jQuery.data( this[i], "olddisplay" ) && display !== "none" ) { + jQuery.data( this[i], "olddisplay", display ); + } } // Set the display of the elements in a second loop diff --git a/test/unit/effects.js b/test/unit/effects.js index 74b336f1..aca92638 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -130,6 +130,41 @@ test("show(Number) - other displays", function() { }); }); + + +// Supports #7397 +test("Persist correct display value", function() { + expect(4); + QUnit.reset(); + stop(); + + // #show-tests * is set display: none in CSS + jQuery("#main").append('
'); + + var $span = jQuery("#show-tests span"), + orig = $span.css("display"), + num = 0; + + equal(orig, "none", "Expecting to start at display: none"); + + $span.text('Saving...').fadeIn(100, function() { + + equal($span.css("display"), "block", "Expecting display: block"); + + $span.text('Saved!').fadeOut(100, function () { + + equal($span.css("display"), "none", "Expecting display: none"); + + $span.text('Saving...').fadeIn(100, function() { + + equal($span.css("display"), "block", "Expecting display: block"); + + start(); + }); + }); + }); +}); + test("animate(Hash, Object, Function)", function() { expect(1); stop();