aboutsummaryrefslogtreecommitdiffstats
path: root/src/css.js
diff options
context:
space:
mode:
authorgnarf <gnarf@gnarf.net>2011-06-20 04:39:12 -0500
committergnarf <gnarf@gnarf.net>2011-06-20 14:21:44 -0500
commit15cd7d83a96da8885938dbdf8f2e7d85bc09777a (patch)
tree61c4d0ad9b5f68a6ce596bc4caf82da1eb0e7894 /src/css.js
parent96501d38a935187461d45c40f17f8327b2e7cd91 (diff)
downloadjquery-15cd7d83a96da8885938dbdf8f2e7d85bc09777a.tar.gz
jquery-15cd7d83a96da8885938dbdf8f2e7d85bc09777a.zip
CSS: Remove filter from style when setting opacity to 1 - Fixes #6652 - REMOVE FILTER:ALPHA(OPACITY=100) AFTER ANIMATION
Diffstat (limited to 'src/css.js')
-rw-r--r--src/css.js23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/css.js b/src/css.js
index cb7df9f80..0d12f073b 100644
--- a/src/css.js
+++ b/src/css.js
@@ -2,6 +2,7 @@
var ralpha = /alpha\([^)]*\)/i,
ropacity = /opacity=([^)]*)/,
+ rfilter = /filter:[^;]*;?/i,
// fixed for IE9, see #8346
rupper = /([A-Z]|^ms)/g,
rnumpx = /^-?\d+(?:px)?$/i,
@@ -211,18 +212,28 @@ if ( !jQuery.support.opacity ) {
set: function( elem, value ) {
var style = elem.style,
- currentStyle = elem.currentStyle;
+ currentStyle = elem.currentStyle,
+ opacity = jQuery.isNaN( value ) ? "" : "alpha(opacity=" + value * 100 + ")",
+ filter = currentStyle && currentStyle.filter || style.filter || "";
// IE has trouble with opacity if it does not have layout
// Force it by setting the zoom level
style.zoom = 1;
- // Set the alpha filter to set the opacity
- var opacity = jQuery.isNaN( value ) ?
- "" :
- "alpha(opacity=" + value * 100 + ")",
- filter = currentStyle && currentStyle.filter || style.filter || "";
+ // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
+ if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" ) {
+
+ // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
+ // if "filter:" is present at all, clearType is disabled, we want to avoid this
+ style.cssText = style.cssText.replace( rfilter, "" );
+
+ // if there there is no filter style applied in a css rule, we are done
+ if ( currentStyle && !currentStyle.filter ) {
+ return;
+ }
+ }
+ // otherwise, set new filter values
style.filter = ralpha.test( filter ) ?
filter.replace( ralpha, opacity ) :
filter + " " + opacity;