X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fcss.js;h=d0e55db0f4ed1b040a06e722e2374f8c01d51f10;hb=b0dcc1746f58f5aca17a12794dd928c0deaaa6a0;hp=8751860a8294843c6a48b77a3753eed17695274d;hpb=543db64412b37b5fa1f3d7fea19f62d6db993fb0;p=jquery.git diff --git a/src/css.js b/src/css.js index 8751860..d0e55db 100644 --- a/src/css.js +++ b/src/css.js @@ -70,7 +70,7 @@ jQuery.extend({ style: function( elem, name, value, extra ) { // Don't set styles on text and comment nodes if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { - return undefined; + return; } // Make sure that we're working with the right name @@ -81,6 +81,11 @@ jQuery.extend({ // Check if we're setting a value if ( value !== undefined ) { + // Make sure that NaN and null values aren't set. See: #7116 + if ( typeof value === "number" && isNaN( value ) || value == null ) { + return; + } + // If a number was passed in, add 'px' to the (except for certain CSS properties) if ( typeof value === "number" && !jQuery.cssNumber[ origName ] ) { value += "px"; @@ -88,7 +93,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 {