From a8d0c823f5a09de02f4de85d40f7a38edf63d79d Mon Sep 17 00:00:00 2001 From: Karl Swedberg Date: Tue, 26 Oct 2010 11:00:21 -0400 Subject: [PATCH] For .show() with no arguments, only set display of elements in the second loop if they don't have style.display already set or if style.display isn't "none". Fixes #7315 --- src/effects.js | 4 +++- test/unit/effects.js | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/effects.js b/src/effects.js index 44a7942e359..34f1353999a 100644 --- a/src/effects.js +++ b/src/effects.js @@ -36,7 +36,9 @@ jQuery.fn.extend({ // Set the display of most of the elements in a second loop // to avoid the constant reflow for ( i = 0; i < j; i++ ) { - this[i].style.display = jQuery.data(this[i], "olddisplay") || ""; + if ( this[i].style.display === "" || this[i].style.display === "none" ) { + this[i].style.display = jQuery.data(this[i], "olddisplay") || ""; + } } return this; diff --git a/test/unit/effects.js b/test/unit/effects.js index 952afc5b1e7..0114b0f4c60 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -6,7 +6,20 @@ test("sanity check", function() { }); test("show()", function() { - expect(23); + expect(26); + + var hiddendiv = jQuery("div.hidden"); + + equal(jQuery.css( hiddendiv[0], "display"), "none", "hiddendiv is display: none"); + + hiddendiv.css("display", "block"); + equal(jQuery.css( hiddendiv[0], "display"), "block", "hiddendiv is display: block"); + + hiddendiv.show(); + equal(jQuery.css( hiddendiv[0], "display"), "block", "hiddendiv is display: block"); + + hiddendiv.css("display",""); + var pass = true, div = jQuery("#main div"); div.show().each(function(){ if ( this.style.display == "none" ) pass = false;