Skip to content

Commit 795e880

Browse files
rwaldronjeresig
authored andcommitted
Fixes #7397; Adds 4 supporting unit tests.
1 parent a64dc04 commit 795e880

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed

src/effects.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ jQuery.fn.extend({
6161
} else {
6262
for ( var i = 0, j = this.length; i < j; i++ ) {
6363
var display = jQuery.css( this[i], "display" );
64-
65-
if ( display !== "none" ) {
66-
jQuery.data( this[i], "olddisplay", display );
67-
}
64+
65+
if ( !jQuery.data( this[i], "olddisplay" ) && display !== "none" ) {
66+
jQuery.data( this[i], "olddisplay", display );
67+
}
6868
}
6969

7070
// Set the display of the elements in a second loop

test/unit/effects.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,41 @@ test("show(Number) - other displays", function() {
130130
});
131131
});
132132

133+
134+
135+
// Supports #7397
136+
test("Persist correct display value", function() {
137+
expect(4);
138+
QUnit.reset();
139+
stop();
140+
141+
// #show-tests * is set display: none in CSS
142+
jQuery("#main").append('<div id="show-tests"><span style="position:absolute;"></span></div>');
143+
144+
var $span = jQuery("#show-tests span"),
145+
orig = $span.css("display"),
146+
num = 0;
147+
148+
equal(orig, "none", "Expecting to start at display: none");
149+
150+
$span.text('Saving...').fadeIn(100, function() {
151+
152+
equal($span.css("display"), "block", "Expecting display: block");
153+
154+
$span.text('Saved!').fadeOut(100, function () {
155+
156+
equal($span.css("display"), "none", "Expecting display: none");
157+
158+
$span.text('Saving...').fadeIn(100, function() {
159+
160+
equal($span.css("display"), "block", "Expecting display: block");
161+
162+
start();
163+
});
164+
});
165+
});
166+
});
167+
133168
test("animate(Hash, Object, Function)", function() {
134169
expect(1);
135170
stop();

0 commit comments

Comments
 (0)