aboutsummaryrefslogtreecommitdiffstats
path: root/src/attributes.js
diff options
context:
space:
mode:
authortimmywil <tim.willison@thisismedium.com>2011-05-04 00:31:01 -0400
committertimmywil <tim.willison@thisismedium.com>2011-05-04 00:31:01 -0400
commit97144424ccb79e251d6df354384fa3e4d5362949 (patch)
tree7edf213beea8631edf3cb61a77b6d7388b489ad2 /src/attributes.js
parenta9d9f8c5422f171d9c451385fcfd7ed1661ec514 (diff)
downloadjquery-97144424ccb79e251d6df354384fa3e4d5362949.tar.gz
jquery-97144424ccb79e251d6df354384fa3e4d5362949.zip
Update boolean check to avoid crashes, add all name fixes to propFix (properties are case-sensitive in all browsers), add tests for prop
Diffstat (limited to 'src/attributes.js')
-rw-r--r--src/attributes.js36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/attributes.js b/src/attributes.js
index 9db69abcc..da63a3334 100644
--- a/src/attributes.js
+++ b/src/attributes.js
@@ -337,9 +337,12 @@ jQuery.extend({
return hooks.get( elem, name );
} else {
- var boolProp = elem[ jQuery.propFix[ name ] || name ];
+ var boolProp;
- if ( typeof boolProp === "boolean" ) {
+ // Align boolean attributes with corresponding properties
+ // Do not check the property if the name contains characters
+ // valid for attributes, but not for properties
+ if ( !rinvalidChar.test( name ) && typeof (boolProp = elem[ jQuery.propFix[ name ] || name ]) === "boolean" ) {
return boolProp ?
name.toLowerCase() :
undefined;
@@ -354,7 +357,7 @@ jQuery.extend({
}
}
},
-
+
removeAttr: function( elem, name ) {
if ( elem.nodeType === 1 ) {
name = jQuery.attrFix[ name ] || name;
@@ -404,7 +407,17 @@ jQuery.extend({
},
propFix: {
- readonly: "readOnly"
+ tabindex: "tabIndex",
+ readonly: "readOnly",
+ "for": "htmlFor",
+ "class": "className",
+ maxlength: "maxLength",
+ cellspacing: "cellSpacing",
+ cellpadding: "cellPadding",
+ rowspan: "rowSpan",
+ colspan: "colSpan",
+ usemap: "useMap",
+ frameborder: "frameBorder"
},
prop: function( elem, name, value ) {
@@ -446,18 +459,9 @@ jQuery.extend({
// IE6/7 do not support getting/setting some attributes with get/setAttribute
if ( !jQuery.support.getSetAttribute ) {
- jQuery.attrFix = jQuery.extend( jQuery.attrFix, {
- readonly: "readOnly",
- "for": "htmlFor",
- "class": "className",
- maxlength: "maxLength",
- cellspacing: "cellSpacing",
- cellpadding: "cellPadding",
- rowspan: "rowSpan",
- colspan: "colSpan",
- usemap: "useMap",
- frameborder: "frameBorder"
- });
+
+ // propFix is more comprehensive and contains all fixes
+ jQuery.attrFix = jQuery.propFix;
// Use this for any attribute on a form in IE6/7
formHook = jQuery.attrHooks.name = jQuery.attrHooks.value = jQuery.valHooks.button = {