From: timmywil Date: Sun, 3 Apr 2011 22:47:44 +0000 (-0400) Subject: Normalize css property names to lowercase for comparisons on a .attr('style') call... X-Git-Tag: 1.6b1~27^2~5 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6f79bee3e3ea874f27389a7e691c1bd7541f2ef6;p=jquery.git Normalize css property names to lowercase for comparisons on a .attr('style') call since IE uppercases everything --- diff --git a/src/attributes.js b/src/attributes.js index ced9977e4..15d4d50e0 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -477,7 +477,8 @@ if ( !jQuery.support.style ) { jQuery.attrHooks.style = { get: function( elem ) { // Return undefined in the case of empty string - return elem.style.cssText || undefined; + // Normalize to lowercase since IE uppercases css property names + return elem.style.cssText.toLowerCase() || undefined; }, set: function( elem, value ) { return (elem.style.cssText = "" + value); diff --git a/test/unit/attributes.js b/test/unit/attributes.js index 0e86a8bf6..4289bc3b7 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -135,8 +135,8 @@ test("attr(String)", function() { equals( $img.attr('height'), "53", "Retrieve height attribute an an element with display:none." ); // Check for style support - ok( !!~jQuery('#dl').attr('style').indexOf('absolute'), 'Check style attribute getter' ); - ok( !!~jQuery('#foo').attr('style', 'position:absolute;').attr('style').indexOf('absolute'), 'Check style setter' ); + ok( !!~jQuery('#dl').attr('style').indexOf('position'), 'Check style attribute getter, also normalize css props to lowercase' ); + ok( !!~jQuery('#foo').attr('style', 'position:absolute;').attr('style').indexOf('position'), 'Check style setter' ); ok( jQuery("
").attr("doesntexist") === undefined, "Make sure undefined is returned when no attribute is found." ); ok( jQuery().attr("doesntexist") === undefined, "Make sure undefined is returned when no element is there." );