From 3c89e38fc26ef40797b83ba8ef4f8329b08afe75 Mon Sep 17 00:00:00 2001 From: jeresig Date: Sat, 5 Dec 2009 21:06:14 -0500 Subject: [PATCH] Make sure that animated show resets the display correctly. Fixes #5130. --- src/fx.js | 4 +++- test/unit/fx.js | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/fx.js b/src/fx.js index fa17072..529fd4c 100644 --- a/src/fx.js +++ b/src/fx.js @@ -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"; } diff --git a/test/unit/fx.js b/test/unit/fx.js index 5b97dc3..9b2f9d8 100644 --- a/test/unit/fx.js +++ b/test/unit/fx.js @@ -41,6 +41,43 @@ test("show()", function() { }); }); +test("show(Number) - other displays", function() { + expect(15); + reset(); + stop(); + + jQuery("#main").append('

'); + + 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(); -- 1.7.10.4