From: John Resig Date: Mon, 11 Oct 2010 20:44:12 +0000 (-0400) Subject: Merge branch 'animateHooks' of http://github.com/lrbabe/jquery into lrbabe-animateHooks X-Git-Url: http://git.asbjorn.it/?a=commitdiff_plain;h=d23f63b13ea47ac3e91906e5ac1e2503400cd903;hp=aa9e4db1ab5cd6f514de616070829d64d69a3428;p=jquery.git Merge branch 'animateHooks' of github.com/lrbabe/jquery into lrbabe-animateHooks --- diff --git a/src/css.js b/src/css.js index d0e55db..933d2b4 100644 --- a/src/css.js +++ b/src/css.js @@ -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; diff --git a/src/effects.js b/src/effects.js index 8c0985b..7d2cd8f 100644 --- a/src/effects.js +++ b/src/effects.js @@ -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 ); } } diff --git a/test/unit/css.js b/test/unit/css.js index 8a49096..632464b 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -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('
').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'}); diff --git a/test/unit/effects.js b/test/unit/effects.js index 3c4015a..2dfe834 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -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("
").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("
").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(); + }); + }); +});