Merge branch 'animateHooks' of http://github.com/lrbabe/jquery into lrbabe-animateHooks
authorJohn Resig <jeresig@gmail.com>
Mon, 11 Oct 2010 20:44:12 +0000 (16:44 -0400)
committerJohn Resig <jeresig@gmail.com>
Mon, 11 Oct 2010 20:44:12 +0000 (16:44 -0400)
src/css.js
src/effects.js
test/unit/css.js
test/unit/effects.js

index d0e55db..933d2b4 100644 (file)
@@ -230,6 +230,9 @@ if ( getComputedStyle ) {
 
                if ( (computedStyle = defaultView.getComputedStyle( elem, null )) ) {
                        ret = computedStyle.getPropertyValue( name );
+                       if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
+                               ret = jQuery.style( elem, name );
+                       }
                }
 
                return ret;
index 8c0985b..7d2cd8f 100644 (file)
@@ -49,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 );
                                }
                        }
 
index 8a49096..632464b 100644 (file)
@@ -1,7 +1,7 @@
 module("css");
 
 test("css(String|Hash)", function() {
-       expect(33);
+       expect(34);
 
        equals( jQuery('#main').css("display"), 'block', 'Check for css property "display"');
 
@@ -19,6 +19,8 @@ test("css(String|Hash)", function() {
        equals( parseFloat(jQuery('#nothiddendiv').css('width')), width, 'Test negative width ignored')
        equals( parseFloat(jQuery('#nothiddendiv').css('height')), height, 'Test negative height ignored')
 
+       equals( jQuery('<div style="display: none;">').css('display'), 'none', 'Styles on disconnected nodes');
+
        jQuery('#floatTest').css({'float': 'right'});
        equals( jQuery('#floatTest').css('float'), 'right', 'Modified CSS float using "float": Assert float is right');
        jQuery('#floatTest').css({'font-size': '30px'});
index 3c4015a..2dfe834 100644 (file)
@@ -770,3 +770,33 @@ test("animate with per-property easing", function(){
        });
 
 });
+
+test("hide hidden elements (bug #7141)", function() {
+       expect(3);
+       QUnit.reset();
+
+       var div = jQuery("<div style='display:none'></div>").appendTo("#main");
+       equals( div.css("display"), "none", "Element is hidden by default" );
+       div.hide();
+       ok( !div.data("olddisplay"), "olddisplay is undefined after hiding an already-hidden element" );
+       div.show();
+       equals( div.css("display"), "block", "Show a double-hidden element" );
+
+       div.remove();
+});
+
+test("hide hidden elements, with animation (bug #7141)", function() {
+       expect(3);
+       QUnit.reset();
+       stop();
+       
+       var div = jQuery("<div style='display:none'></div>").appendTo("#main");
+       equals( div.css("display"), "none", "Element is hidden by default" );
+       div.hide(1, function () {
+               ok( !div.data("olddisplay"), "olddisplay is undefined after hiding an already-hidden element" );
+               div.show(1, function () {
+                       equals( div.css("display"), "block", "Show a double-hidden element" );
+                       start();
+               });
+       });
+});