From 7ad613c5e9aaf79666c5de39ebfafad5c46e13b9 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Thu, 22 Mar 2007 01:37:28 +0000 Subject: [PATCH] Update to fix for #1064 and tests --- src/jquery/coreTest.js | 8 ++++---- src/jquery/jquery.js | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/jquery/coreTest.js b/src/jquery/coreTest.js index 4370e9da8..896130011 100644 --- a/src/jquery/coreTest.js +++ b/src/jquery/coreTest.js @@ -261,9 +261,9 @@ test("css(String|Hash)", function() { $.each("0,0.25,0.5,0.75,1".split(','), function(i, n) { $('#foo').css({opacity: n}); - ok( $('#foo').css('opacity') == n, "Assert opacity is " + n + " as a String" ); + ok( $('#foo').css('opacity') == parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" ); $('#foo').css({opacity: parseFloat(n)}); - ok( $('#foo').css('opacity') == n, "Assert opacity is " + n + " as a Number" ); + ok( $('#foo').css('opacity') == parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" ); }); $('#foo').css({opacity: ''}); ok( $('#foo').css('opacity') == '1', "Assert opacity is 1 when set to an empty String" ); @@ -288,9 +288,9 @@ test("css(String, Object)", function() { $.each("0,0.25,0.5,0.75,1".split(','), function(i, n) { $('#foo').css('opacity', n); - ok( $('#foo').css('opacity') == n, "Assert opacity is " + n + " as a String" ); + ok( $('#foo').css('opacity') == parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" ); $('#foo').css('opacity', parseFloat(n)); - ok( $('#foo').css('opacity') == n, "Assert opacity is " + n + " as a Number" ); + ok( $('#foo').css('opacity') == parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" ); }); $('#foo').css('opacity', ''); ok( $('#foo').css('opacity') == '1', "Assert opacity is 1 when set to an empty String" ); diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index 30396cacc..84a159433 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -1403,8 +1403,10 @@ jQuery.extend({ curCSS: function(elem, prop, force) { var ret; - if (prop == "opacity" && jQuery.browser.msie) - return jQuery.attr(elem.style, "opacity"); + if (prop == "opacity" && jQuery.browser.msie) { + ret = jQuery.attr(elem.style, "opacity"); + return ret == "" ? "1" : ret; + } if (prop == "float" || prop == "cssFloat") prop = jQuery.browser.msie ? "styleFloat" : "cssFloat"; @@ -1537,7 +1539,7 @@ jQuery.extend({ } return elem.filter ? - (parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100).toString() : "1"; + (parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100).toString() : ""; } // Certain attributes only work when accessed via the old DOM 0 way