]> source.dussan.org Git - jquery.git/commitdiff
Prevent IE from throwing errors when setting RGBA values. Fixes #5509.
authorColin Snover <colin@alpha.zetafleet.com>
Sat, 9 Oct 2010 14:42:01 +0000 (10:42 -0400)
committerjeresig <jeresig@gmail.com>
Sat, 9 Oct 2010 14:42:01 +0000 (10:42 -0400)
src/css.js
test/unit/css.js

index 4bf818e5abeae651d2ee0c24e6f9fd6645cb7fad..99cb73581cd4430aeeb8bd2696b364514e0f849d 100644 (file)
@@ -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 {
index 468f763865c2fafb43fe1404edb496ffcdce2121..26dd7047d437be5af431043cc75a9e45027c0fc0 100644 (file)
@@ -64,7 +64,7 @@ test("css(String|Hash)", function() {
 });
 
 test("css(String, Object)", function() {
-       expect(21);
+       expect(22);
 
        ok( jQuery('#nothiddendiv').is(':visible'), 'Modifying CSS display: Assert element is visible');
        jQuery('#nothiddendiv').css("display", 'none');
@@ -104,6 +104,16 @@ test("css(String, Object)", function() {
 
        equals( ret, div, "Make sure setting undefined returns the original set." );
        equals( div.css("display"), display, "Make sure that the display wasn't changed." );
+
+       // Test for Bug #5509
+       var success = true;
+       try {
+               jQuery('#foo').css("backgroundColor", "rgba(0, 0, 0, 0.1)");
+       }
+       catch (e) {
+               success = false;
+       }
+       ok( success, "Setting RGBA values does not throw Error" );
 });
 
 if(jQuery.browser.msie) {