From e9e7db412ba3c7bc306b609c239dced20c61dda1 Mon Sep 17 00:00:00 2001 From: rwldrn Date: Wed, 17 Aug 2011 16:29:55 -0400 Subject: [PATCH] Landing pull request 466. Test if opacity is not expected val. Fixes effects test suite. More Details: - https://github.com/jquery/jquery/pull/466 --- test/unit/effects.js | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/test/unit/effects.js b/test/unit/effects.js index a22deba5b..6ff1ce5c3 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -169,7 +169,7 @@ test("Persist correct display value", function() { test("show() resolves correct default display #8099", function() { expect(7); - var tt8099 = jQuery("").appendTo("body"), + var tt8099 = jQuery("").appendTo("body"), dfn8099 = jQuery("", { html: "foo"}).appendTo("body"); equals( tt8099.css("display"), "none", "default display override for all tt" ); @@ -726,6 +726,7 @@ jQuery.each( { var f_h = f( elem, "height" ); var t_o = t( elem, "opacity" ); var f_o = f( elem, "opacity" ); + if ( f_o === "" ) { f_o = 1; } @@ -753,22 +754,39 @@ jQuery.each( { elem = elem[ 0 ]; - if ( t_w == "show" ) + if ( t_w == "show" ) { equals( elem.style.display, "block", "Showing, display should block: " + elem.style.display); + } - if ( t_w == "hide"||t_w == "show" ) + if ( t_w == "hide"||t_w == "show" ) { ok(f_w === "" ? elem.style.width === f_w : elem.style.width.indexOf(f_w) === 0, "Width must be reset to " + f_w + ": " + elem.style.width); + } - if ( t_h == "hide"||t_h == "show" ) + if ( t_h == "hide"||t_h == "show" ) { ok(f_h === "" ? elem.style.height === f_h : elem.style.height.indexOf(f_h) === 0, "Height must be reset to " + f_h + ": " + elem.style.height); + } + + var cur_o = jQuery.style(elem, "opacity"); + + if ( f_o !== jQuery.css(elem, "opacity") ) { + f_o = f( elem, "opacity" ); + } + + if ( f_o === "" ) { + f_o = 1; + } - var cur_o = jQuery.css(elem, "opacity"); + if ( cur_o === "" ) { + cur_o = 1; + } - if ( t_o == "hide" || t_o == "show" ) + if ( t_o == "hide" || t_o == "show" ) { equals(cur_o, f_o, "Opacity must be reset to " + f_o + ": " + cur_o); + } - if ( t_w == "hide" ) + if ( t_w == "hide" ) { equals(elem.style.display, "none", "Hiding, display should be none: " + elem.style.display); + } if ( t_o.constructor == Number ) { equals(cur_o, t_o, "Final opacity should be " + t_o + ": " + cur_o); -- 2.39.5