Skip to content

Commit

Permalink
Make sure that animated show resets the display correctly. Fixes #5130.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeresig committed Dec 6, 2009
1 parent 2d27e05 commit 3c89e38
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/fx.js
Expand Up @@ -359,7 +359,9 @@ jQuery.fx.prototype = {
this.elem.style.overflow = this.options.overflow;

// Reset the display
this.elem.style.display = this.options.display;
var old = jQuery.data(this.elem, "olddisplay");
this.elem.style.display = old ? old : this.options.display;

if ( jQuery.css(this.elem, "display") == "none" ) {
this.elem.style.display = "block";
}
Expand Down
37 changes: 37 additions & 0 deletions test/unit/fx.js
Expand Up @@ -41,6 +41,43 @@ test("show()", function() {
});
});

test("show(Number) - other displays", function() {
expect(15);
reset();
stop();

jQuery("#main").append('<div id="show-tests"><div><p><a href="#"></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div>');

var old = jQuery("#show-tests table").show().css("display") !== "table",
num = 0;

var test = {
"div" : "block",
"p" : "block",
"a" : "inline",
"code" : "inline",
"pre" : "block",
"span" : "inline",
"table" : old ? "block" : "table",
"thead" : old ? "block" : "table-header-group",
"tbody" : old ? "block" : "table-row-group",
"tr" : old ? "block" : "table-row",
"th" : old ? "block" : "table-cell",
"td" : old ? "block" : "table-cell",
"ul" : "block",
"li" : old ? "block" : "list-item"
};

jQuery.each(test, function(selector, expected) {
var elem = jQuery(selector, "#show-tests").show(1, function() {
equals( elem.css("display"), expected, "Show using correct display type for " + selector );
if ( ++num === 15 ) {
start();
}
});
});
});

test("animate(Hash, Object, Function)", function() {
expect(1);
stop();
Expand Down

1 comment on commit 3c89e38

@jeresig
Copy link
Member Author

@jeresig jeresig commented on 3c89e38 Dec 6, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.