From d938c6bbd6b220f122c50f5f828b8f0cd818c168 Mon Sep 17 00:00:00 2001 From: David Serduke Date: Tue, 4 Dec 2007 18:15:27 +0000 Subject: [PATCH] Fixed #1438 where a filter could be set in IE but not have opacity in it. The JS error was fixed by checking to make sure 'opacity=' is in the filter before seeing what its value is. --- src/core.js | 2 +- test/unit/core.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/core.js b/src/core.js index bd6d929..5a842d5 100644 --- a/src/core.js +++ b/src/core.js @@ -1064,7 +1064,7 @@ jQuery.extend({ (parseFloat( value ).toString() == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")"); } - return elem.filter ? + return elem.filter && elem.filter.indexOf("opacity=") >= 0 ? (parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100).toString() : ""; } diff --git a/test/unit/core.js b/test/unit/core.js index a1ebb1b..f40f3b0 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -380,7 +380,7 @@ test("css(String|Hash)", function() { }); test("css(String, Object)", function() { - expect(18); + expect(19); ok( $('#foo').is(':visible'), 'Modifying CSS display: Assert element is visible'); $('#foo').css('display', 'none'); ok( !$('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden'); @@ -404,6 +404,11 @@ test("css(String, Object)", function() { }); $('#foo').css('opacity', ''); ok( $('#foo').css('opacity') == '1', "Assert opacity is 1 when set to an empty String" ); + // for #1438, IE throws JS error when filter exists but doesn't have opacity in it + if (jQuery.browser.msie) { + $('#foo').css("filter", "progid:DXImageTransform.Microsoft.Chroma(color='red');"); + } + equals( $('#foo').css('opacity'), '1', "Assert opacity is 1 when a different filter is set in IE, #1438" ); }); test("jQuery.css(elem, 'height') doesn't clear radio buttons (bug #1095)", function () { -- 1.7.10.4