Skip to content

Commit

Permalink
Fixes #13088: under IE8, $(selector).attr('style') always return lowe…
Browse files Browse the repository at this point in the history
…rcase string
  • Loading branch information
mikesherov committed Dec 31, 2012
1 parent c9b75df commit abead1c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/attributes.js
Expand Up @@ -600,8 +600,9 @@ if ( !jQuery.support.style ) {
jQuery.attrHooks.style = {
get: function( elem ) {
// Return undefined in the case of empty string
// Normalize to lowercase since IE uppercases css property names
return elem.style.cssText.toLowerCase() || undefined;
// Note: IE uppercases css property names, but if we were to .toLowerCase()
// .cssText, that would destroy case senstitivity in URL's, like in "background"
return elem.style.cssText || undefined;
},
set: function( elem, value ) {
return ( elem.style.cssText = value + "" );
Expand Down
7 changes: 5 additions & 2 deletions test/unit/attributes.js
Expand Up @@ -130,8 +130,11 @@ test( "attr(String)", function() {
equal( $img.attr("height"), "53", "Retrieve height attribute an an element with display:none." );

// Check for style support
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" );
var styleElem = jQuery("<div/>").appendTo("#qunit-fixture").css({
background: "url(UPPERlower.gif)"
});
ok( !!~styleElem.attr("style").indexOf("UPPERlower.gif"), "Check style attribute getter" );
ok( !!~styleElem.attr("style", "position:absolute;").attr("style").indexOf("absolute"), "Check style setter" );

// Check value on button element (#1954)
var $button = jQuery("<button>text</button>").insertAfter("#button");
Expand Down

0 comments on commit abead1c

Please sign in to comment.