diff --git a/CHANGELOG b/CHANGELOG index 7dc1131..a869c4b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Element.setOpacity now calls removeAttribute on the filter style on IE if no more filters remain, which makes Cleartype work properly. Closes #8376. [alexdemi, Thomas Fuchs] + * Event.findElement now uses Element#up (and as a result can take a CSS selector instead of just a tag name). [Tobie Langel] * Minor cleanup of the position methods [sam] diff --git a/src/dom.js b/src/dom.js index 8ce66e4..b17999b 100644 --- a/src/dom.js +++ b/src/dom.js @@ -689,13 +689,17 @@ else if (Prototype.Browser.IE) { }; Element.Methods.setOpacity = function(element, value) { + function stripAlpha(filter){ + return filter.replace(/alpha\([^\)]*\)/gi,''); + } element = $(element); var filter = element.getStyle('filter'), style = element.style; if (value == 1 || value === '') { - style.filter = filter.replace(/alpha\([^\)]*\)/gi,''); + (filter = stripAlpha(filter)) ? + style.filter = filter : style.removeAttribute('filter'); return element; } else if (value < 0.00001) value = 0; - style.filter = filter.replace(/alpha\([^\)]*\)/gi, '') + + style.filter = stripAlpha(filter) + 'alpha(opacity=' + (value * 100) + ')'; return element; }; diff --git a/test/unit/dom.html b/test/unit/dom.html index aa2e1e1..55e9425 100644 --- a/test/unit/dom.html +++ b/test/unit/dom.html @@ -894,6 +894,7 @@ assert( $('style_test_3').setOpacity(0.9999999).getStyle('opacity') > 0.999 ); + }}, testElementGetStyle: function() { with(this) {