X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fcss.js;h=99cb73581cd4430aeeb8bd2696b364514e0f849d;hb=2ca36598954759c5b5dce569a39c52b981ed4ab2;hp=07ff686d0742635e0294dfa057af007753694c69;hpb=0be7f4eb4f027dce00f11d7816290022d447d336;p=jquery.git diff --git a/src/css.js b/src/css.js index 07ff686..99cb735 100644 --- a/src/css.js +++ b/src/css.js @@ -1,6 +1,6 @@ (function( jQuery ) { -var ralpha = /alpha\([^)]*\)/, +var ralpha = /alpha\([^)]*\)/i, ropacity = /opacity=([^)]*)/, rdashAlpha = /-([a-z])/ig, rupper = /([A-Z])/g, @@ -20,6 +20,11 @@ var ralpha = /alpha\([^)]*\)/, }; jQuery.fn.css = function( name, value ) { + // Setting 'undefined' is a no-op + if ( arguments.length === 2 && value === undefined ) { + return this; + } + return jQuery.access( this, name, value, true, function( elem, name, value ) { return value !== undefined ? jQuery.style( elem, name, value ) : @@ -83,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 { @@ -199,7 +208,7 @@ if ( !jQuery.support.opacity ) { style.filter = ralpha.test(filter) ? filter.replace(ralpha, opacity) : - opacity; + style.filter + ' ' + opacity; } }; }