Fix olddisplay was inappropriately set when calling hide on an already hidden element...
[jquery.git] / src / effects.js
index 4b9c7cc..8662df5 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));
                                }
                        }
@@ -66,9 +49,10 @@ jQuery.fn.extend({
 
                } else {
                        for ( var i = 0, j = this.length; i < j; i++ ) {
-                               var old = jQuery.data(this[i], "olddisplay");
-                               if ( !old ) {
-                                       jQuery.data( this[i], "olddisplay", jQuery.css( this[i], "display" ) );
+                               var display = jQuery.css( this[i], "display" );
+
+                               if ( display !== "none" ) {
+                                       jQuery.data( this[i], "olddisplay", display );
                                }
                        }
 
@@ -149,9 +133,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 +144,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;
                                                        }
@@ -175,7 +160,7 @@ jQuery.fn.extend({
                                }
                        }
 
-                       if ( opt.overflow != null || (jQuery.support.shrinkWrapBlocks && isElement) ) {
+                       if ( opt.overflow != null ) {
                                this.style.overflow = "hidden";
                        }
 
@@ -408,10 +393,11 @@ jQuery.fx.prototype = {
 
                        if ( done ) {
                                // Reset the overflow
-                               if ( this.options.overflow != null && (!jQuery.support.shrinkWrapBlocks || !jQuery.css( this.elem, "hasLayout" )) ) {
-                                       this.elem.style.overflow = this.options.overflow[0];
-                                       this.elem.style.overflowX = this.options.overflow[1];
-                                       this.elem.style.overflowY = this.options.overflow[2];
+                               if ( this.options.overflow != null && !jQuery.support.shrinkWrapBlocks ) {
+                                       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 +488,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 );