Prevent IE from throwing errors when setting RGBA values. Fixes #5509.
[jquery.git] / src / css.js
index 61cdc48..99cb735 100644 (file)
@@ -1,6 +1,6 @@
 (function( jQuery ) {
 
-var ralpha = /alpha\([^)]*\)/,
+var ralpha = /alpha\([^)]*\)/i,
        ropacity = /opacity=([^)]*)/,
        rdashAlpha = /-([a-z])/ig,
        rupper = /([A-Z])/g,
@@ -88,7 +88,11 @@ jQuery.extend({
 
                        // If a hook was provided, use that value, otherwise just set the specified value
                        if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value )) !== undefined ) {
-                               style[ name ] = value;
+                               // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
+                               // Fixes bug #5509
+                               try {
+                                       style[ name ] = value;
+                               } catch(e) {}
                        }
 
                } else {
@@ -204,7 +208,7 @@ if ( !jQuery.support.opacity ) {
 
                        style.filter = ralpha.test(filter) ?
                                filter.replace(ralpha, opacity) :
-                               opacity;
+                               style.filter + ' ' + opacity;
                }
        };
 }