]> source.dussan.org Git - jquery.git/commitdiff
Fix olddisplay was inappropriately set when calling hide on an already hidden element... 49/head
authorColin Snover <github.com@zetafleet.com>
Mon, 11 Oct 2010 20:22:43 +0000 (15:22 -0500)
committerColin Snover <github.com@zetafleet.com>
Mon, 11 Oct 2010 20:22:43 +0000 (15:22 -0500)
src/effects.js
test/unit/effects.js

index 241dbd03687afe9bd419b910b0e90bbf487fba2e..8662df5b9eec07825d2e196e1409bba1c8908842 100644 (file)
@@ -49,9 +49,10 @@ jQuery.fn.extend({
 
                } else {
                        for ( var i = 0, j = this.length; i < j; i++ ) {
-                               var old = jQuery.data(this[i], "olddisplay");
-                               if ( !old ) {
-                                       jQuery.data( this[i], "olddisplay", jQuery.css( this[i], "display" ) );
+                               var display = jQuery.css( this[i], "display" );
+
+                               if ( display !== "none" ) {
+                                       jQuery.data( this[i], "olddisplay", display );
                                }
                        }
 
index 3c4015aff61f5fa6f82e87b9edae7f75972244d5..2dfe834b25778a964ab56326404a281b55f7e400 100644 (file)
@@ -770,3 +770,33 @@ test("animate with per-property easing", function(){
        });
 
 });
+
+test("hide hidden elements (bug #7141)", function() {
+       expect(3);
+       QUnit.reset();
+
+       var div = jQuery("<div style='display:none'></div>").appendTo("#main");
+       equals( div.css("display"), "none", "Element is hidden by default" );
+       div.hide();
+       ok( !div.data("olddisplay"), "olddisplay is undefined after hiding an already-hidden element" );
+       div.show();
+       equals( div.css("display"), "block", "Show a double-hidden element" );
+
+       div.remove();
+});
+
+test("hide hidden elements, with animation (bug #7141)", function() {
+       expect(3);
+       QUnit.reset();
+       stop();
+       
+       var div = jQuery("<div style='display:none'></div>").appendTo("#main");
+       equals( div.css("display"), "none", "Element is hidden by default" );
+       div.hide(1, function () {
+               ok( !div.data("olddisplay"), "olddisplay is undefined after hiding an already-hidden element" );
+               div.show(1, function () {
+                       equals( div.css("display"), "block", "Show a double-hidden element" );
+                       start();
+               });
+       });
+});