Skip to content

Commit a8d0c82

Browse files
committed
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
1 parent 7066bb3 commit a8d0c82

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/effects.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ jQuery.fn.extend({
3636
// Set the display of most of the elements in a second loop
3737
// to avoid the constant reflow
3838
for ( i = 0; i < j; i++ ) {
39-
this[i].style.display = jQuery.data(this[i], "olddisplay") || "";
39+
if ( this[i].style.display === "" || this[i].style.display === "none" ) {
40+
this[i].style.display = jQuery.data(this[i], "olddisplay") || "";
41+
}
4042
}
4143

4244
return this;

test/unit/effects.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,20 @@ test("sanity check", function() {
66
});
77

88
test("show()", function() {
9-
expect(23);
9+
expect(26);
10+
11+
var hiddendiv = jQuery("div.hidden");
12+
13+
equal(jQuery.css( hiddendiv[0], "display"), "none", "hiddendiv is display: none");
14+
15+
hiddendiv.css("display", "block");
16+
equal(jQuery.css( hiddendiv[0], "display"), "block", "hiddendiv is display: block");
17+
18+
hiddendiv.show();
19+
equal(jQuery.css( hiddendiv[0], "display"), "block", "hiddendiv is display: block");
20+
21+
hiddendiv.css("display","");
22+
1023
var pass = true, div = jQuery("#main div");
1124
div.show().each(function(){
1225
if ( this.style.display == "none" ) pass = false;

0 commit comments

Comments
 (0)