diff options
author | timmywil <tim.willison@thisismedium.com> | 2011-03-11 14:51:57 -0500 |
---|---|---|
committer | timmywil <tim.willison@thisismedium.com> | 2011-04-03 19:13:38 -0400 |
commit | 4baa213d881a71ffd8557bc587f81d0bc606d63c (patch) | |
tree | 1bd12482b6c5dbcf34853edc80a1abb72d3c1503 /src/attributes.js | |
parent | 607210e01068224ac613558c0a314ad4a8fba247 (diff) | |
download | jquery-4baa213d881a71ffd8557bc587f81d0bc606d63c.tar.gz jquery-4baa213d881a71ffd8557bc587f81d0bc606d63c.zip |
First proposed solution for IE6/7 get/setAttribute quirks. Needs more testing, but solves some issues
Diffstat (limited to 'src/attributes.js')
-rw-r--r-- | src/attributes.js | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/src/attributes.js b/src/attributes.js index 83d02e212..ee4dc1bad 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -275,12 +275,6 @@ jQuery.extend({ offset: true }, - // TODO: Check to see if any of these are needed anymore? - // If not, it may be good to standardize on all-lowercase names instead - attrFix: { - - }, - attr: function( elem, name, value, pass ) { // don't get/set attributes on text, comment and attribute nodes @@ -342,7 +336,7 @@ jQuery.extend({ // Look for the name in elem.attributes.name var attrs = elem.attributes, i = 0, len = attrs.length; for ( ; i < len; i++ ) { - if ( attrs[i]["name"] === name ) { + if ( attrs[i].name === name ) { return true; } } @@ -455,7 +449,7 @@ if ( !jQuery.support.style ) { // Safari mis-reports the default selected property of an option // Accessing the parent's selectedIndex property fixes it if ( !jQuery.support.optSelected ) { - + jQuery.propHooks.selected = { get: function( elem ) { var parent = elem.parentNode; @@ -475,4 +469,31 @@ if ( !jQuery.support.optSelected ) { }; } -})( jQuery ); +// IE6/7 do not support getting/setting some attributes with get/setAttribute + +if ( jQuery.support.attrFix ) { + var attrFix = { + "for": "htmlFor", + "class": "className", + readonly: "readOnly", + maxlength: "maxLength", + cellspacing: "cellSpacing", + rowspan: "rowSpan", + colspan: "colSpan", + tabindex: "tabIndex", + usemap: "useMap", + frameborder: "frameBorder" + }; + + jQuery.each(attrFix, function( key, name ) { + jQuery.attrHooks[ key ] = jQuery.extend( jQuery.attrHooks[ key ], { + get: function( elem ) { + return elem.getAttribute( name ); + }, + set: function( elem, value ) { + elem.setAttribute( name, value ); + return value; + } + }); + }); +}
\ No newline at end of file |