Skip to content

Commit

Permalink
For .show() with no arguments, only set display of elements in the se…
Browse files Browse the repository at this point in the history
…cond loop if they don't have style.display already set or if style.display isn't "none". Fixes #7315
  • Loading branch information
kswedberg committed Oct 26, 2010
1 parent 7066bb3 commit a8d0c82
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/effects.js
Expand Up @@ -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;
Expand Down
15 changes: 14 additions & 1 deletion test/unit/effects.js
Expand Up @@ -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;
Expand Down

0 comments on commit a8d0c82

Please sign in to comment.