]> source.dussan.org Git - jquery.git/commitdiff
Fixed code convention issues. Reduced size of overflow reset code. Fixed broken show... 35/head
authorColin Snover <github.com@zetafleet.com>
Sat, 9 Oct 2010 01:29:41 +0000 (20:29 -0500)
committerColin Snover <github.com@zetafleet.com>
Sat, 9 Oct 2010 01:29:41 +0000 (20:29 -0500)
src/effects.js
src/support.js
test/unit/effects.js

index bcbc565861c64e6562bc4aaf5c3d79b0b8a6fdec..241dbd03687afe9bd419b910b0e90bbf487fba2e 100644 (file)
@@ -13,23 +13,6 @@ var elemdisplay = {},
                [ "opacity" ]
        ];
 
-function defaultDisplay(nodeName) {
-       if ( !elemdisplay[ nodeName ] ) {
-               var elem = jQuery("<" + nodeName + ">").appendTo("body"),
-                       display = elem.css("display");
-
-               elem.remove();
-
-               if ( display === "none" || display === "" ) {
-                       display = "block";
-               }
-
-               elemdisplay[ nodeName ] = display;
-       }
-
-       return elemdisplay[ nodeName ];
-}
-
 jQuery.fn.extend({
        show: function( speed, easing, callback ) {
                if ( speed || speed === 0 ) {
@@ -45,7 +28,7 @@ jQuery.fn.extend({
                                // Set elements which have been overridden with display: none
                                // in a stylesheet to whatever the default browser style is
                                // for such an element
-                               if ( jQuery.css( this[i], "display" ) === "none" && this[i].style.display === "" ) {
+                               if ( this[i].style.display === "" && jQuery.css( this[i], "display" ) === "none" ) {
                                        jQuery.data(this[i], "olddisplay", defaultDisplay(this[i].nodeName));
                                }
                        }
@@ -149,9 +132,10 @@ jQuery.fn.extend({
                                        // animations on inline elements that are having width/height
                                        // animated
                                        if ( jQuery.css( this, "display" ) === "inline" &&
-                                               jQuery.css( this, "float" ) === "none" ) {
+                                                       jQuery.css( this, "float" ) === "none" ) {
                                                if ( !jQuery.support.inlineBlockNeedsLayout ) {
                                                        this.style.display = "inline-block";
+
                                                } else {
                                                        var display = defaultDisplay(this.nodeName);
 
@@ -159,8 +143,8 @@ jQuery.fn.extend({
                                                        // block-level elements need to be inline with layout
                                                        if ( display === "inline" ) {
                                                                this.style.display = "inline-block";
-                                                       }
-                                                       else {
+
+                                                       else {
                                                                this.style.display = "inline";
                                                                this.style.zoom = 1;
                                                        }
@@ -409,9 +393,10 @@ jQuery.fx.prototype = {
                        if ( done ) {
                                // Reset the overflow
                                if ( this.options.overflow != null && !jQuery.support.shrinkWrapBlocks ) {
-                                       this.elem.style.overflow = this.options.overflow[0];
-                                       this.elem.style.overflowX = this.options.overflow[1];
-                                       this.elem.style.overflowY = this.options.overflow[2];
+                                       var elem = this.elem, options = this.options;
+                                       jQuery.each( [ "", "X", "Y" ], function (index, value) {
+                                               elem.style[ "overflow" + value ] = options.overflow[index];
+                                       } );
                                }
 
                                // Hide the element if the "hide" operation was done
@@ -502,4 +487,21 @@ if ( jQuery.expr && jQuery.expr.filters ) {
        };
 }
 
+function defaultDisplay( nodeName ) {
+       if ( !elemdisplay[ nodeName ] ) {
+               var elem = jQuery("<" + nodeName + ">").appendTo("body"),
+                       display = elem.css("display");
+
+               elem.remove();
+
+               if ( display === "none" || display === "" ) {
+                       display = "block";
+               }
+
+               elemdisplay[ nodeName ] = display;
+       }
+
+       return elemdisplay[ nodeName ];
+}
+
 })( jQuery );
index 85deb1b98908a3c2aeb05fb8ff601fa54676b44b..c2ffa45f24154b4011987d5de8e933c7dd13986b 100644 (file)
                document.body.appendChild( div );
                jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
 
-               if ( 'zoom' in div.style ) {
+               if ( "zoom" in div.style ) {
                        // Check if natively block-level elements act like inline-block
                        // elements when setting their display to 'inline' and giving
                        // them layout
                        // (IE < 8 does this)
-                       div.style.display = 'inline';
+                       div.style.display = "inline";
                        div.style.zoom = 1;
                        jQuery.support.inlineBlockNeedsLayout = div.offsetWidth === 2;
 
                        // Check if elements with layout shrink-wrap their children
                        // (IE 6 does this)
-                       div.style.display = '';
-                       div.innerHTML = '<div style="width:4px;"></div>';
+                       div.style.display = "";
+                       div.innerHTML = "<div style='width:4px;'></div>";
                        jQuery.support.shrinkWrapBlocks = div.offsetWidth !== 2;
                }
 
-               div.innerHTML = '<table><tr><td style="padding:0;display:none"></td><td>t</td></tr></table>';
-               var tds = div.getElementsByTagName('td');
+               div.innerHTML = "<table><tr><td style='padding:0;display:none'></td><td>t</td></tr></table>";
+               var tds = div.getElementsByTagName("td");
 
                // Check if table cells still have offsetWidth/Height when they are set
                // to display:none and there are still other visible table cells in a
                // (only IE 8 fails this test)
                jQuery.support.reliableHiddenOffsets = tds[0].offsetHeight === 0;
 
-               tds[0].style.display = '';
-               tds[1].style.display = 'none';
+               tds[0].style.display = "";
+               tds[1].style.display = "none";
 
                // Check if empty table cells still have offsetWidth/Height
                // (IE < 8 fail this test)
                jQuery.support.reliableHiddenOffsets = jQuery.support.reliableHiddenOffsets && tds[0].offsetHeight === 0;
-               div.innerHTML = '';
+               div.innerHTML = "";
 
-               document.body.removeChild( div ).style.display = 'none';
+               document.body.removeChild( div ).style.display = "none";
                div = tds = null;
        });
 
index dd95d1ba61b975b524c4c55e3343204bc7f8a758..3c4015aff61f5fa6f82e87b9edae7f75972244d5 100644 (file)
@@ -38,9 +38,10 @@ test("show()", function() {
        });
 
        // #show-tests * is set display: none in CSS
-       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";
+       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><table id="test-table"></table>');
+       
+       var old = jQuery("#test-table").show().css("display") !== "table";
+       jQuery("#test-table").remove();
 
        var test = {
                "div"      : "block",
@@ -71,10 +72,11 @@ test("show(Number) - other displays", function() {
        stop();
 
        // #show-tests * is set display: none in CSS
-       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>');
+       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><table id="test-table"></table>');
 
-       var old = jQuery("#show-tests table").show().css("display") !== "table",
+       var old = jQuery("#test-table").show().css("display") !== "table",
                num = 0;
+       jQuery("#test-table").remove();
 
        var test = {
                "div"      : "block",
@@ -94,10 +96,7 @@ test("show(Number) - other displays", function() {
        };
 
        jQuery.each(test, function(selector, expected) {
-               // IE sometimes has issues with chained functions referencing
-               // assignments from outside the closure
-               var elem = jQuery(selector, "#show-tests");
-               elem.show(1, function() {
+               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();