]> source.dussan.org Git - jquery.git/commitdiff
show is now element aware (#960)
authorBrandon Aaron <brandon.aaron@gmail.com>
Sat, 8 Dec 2007 04:54:53 +0000 (04:54 +0000)
committerBrandon Aaron <brandon.aaron@gmail.com>
Sat, 8 Dec 2007 04:54:53 +0000 (04:54 +0000)
src/fx.js
test/data/testsuite.css
test/unit/core.js

index 52225c8a4d6bbac42b068c6c85bc15f8000aaa93..c613f938dad3dbe58fa5ad328067ccc6bb5c2f6e 100644 (file)
--- a/src/fx.js
+++ b/src/fx.js
@@ -6,9 +6,12 @@ jQuery.fn.extend({
                        }, speed, callback) :
                        
                        this.filter(":hidden").each(function(){
-                               this.style.display = this.oldblock ? this.oldblock : "";
-                               if ( jQuery.css(this,"display") == "none" )
-                                       this.style.display = "block";
+                               this.style.display = this.oldblock || "";
+                               if ( jQuery.css(this,"display") == "none" ) {
+                                       var elem = jQuery("<" + this.tagName + " />").appendTo("body");
+                                       this.style.display = elem.css("display");
+                                       elem.remove();
+                               }
                        }).end();
        },
        
@@ -20,8 +23,6 @@ jQuery.fn.extend({
                        
                        this.filter(":visible").each(function(){
                                this.oldblock = this.oldblock || jQuery.css(this,"display");
-                               if ( this.oldblock == "none" )
-                                       this.oldblock = "block";
                                this.style.display = "none";
                        }).end();
        },
@@ -417,4 +418,4 @@ jQuery.fx.step = {
        _default: function(fx){
                fx.elem.style[ fx.prop ] = fx.now + fx.unit;
        }
-};
+};
\ No newline at end of file
index b15f5ef7f7b2dc6bf33a26ee7138bad5ed0a24e6..4801becd652ab83581f2ffebda3420c563c0d6a4 100644 (file)
@@ -113,3 +113,5 @@ div.chain.test div { background: green; }
 
 div.chain.out { background: green; }
 div.chain.out div { background: red; display: none; }
+
+div#show-tests * { display: none; }
\ No newline at end of file
index 7ba7eb5da712627e1d4ba74d037d793acd8261ef..533fcef2d0637529ba835ec70a3f55417e0ba3eb 100644 (file)
@@ -1106,12 +1106,35 @@ test("prev([String])", function() {
 });
 
 test("show()", function() {
-       expect(1);
+       expect(15);
        var pass = true, div = $("div");
        div.show().each(function(){
                if ( this.style.display == "none" ) pass = false;
        });
        ok( pass, "Show" );
+       
+       $("#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 test = {
+               "div"      : "block",
+               "p"        : "block",
+               "a"        : "inline",
+               "code"     : "inline",
+               "pre"      : "block",
+               "span"     : "inline",
+               "table"    : $.browser.msie ? "block" : "table",
+               "thead"    : $.browser.msie ? "block" : "table-header-group",
+               "tbody"    : $.browser.msie ? "block" : "table-row-group",
+               "tr"       : $.browser.msie ? "block" : "table-row",
+               "th"       : $.browser.msie ? "block" : "table-cell",
+               "td"       : $.browser.msie ? "block" : "table-cell",
+               "ul"       : "block",
+               "li"       : $.browser.msie ? "block" : "list-item"
+       };
+       
+       $.each(test, function(selector, expected) {
+               var elem = $(selector, "#show-tests").show();
+               equals( elem.css("display"), expected, "Show using correct display type for " + selector );
+       });
 });
 
 test("addClass(String)", function() {