define([
"../core",
- "../var/rnotwhite",
"../core/access",
"./support",
+ "../var/rnotwhite",
"../selector"
-], function( jQuery, rnotwhite, access, support ) {
+], function( jQuery, access, support, rnotwhite ) {
var boolHook,
attrHandle = jQuery.expr.attrHandle;
jQuery.extend({
attr: function( elem, name, value ) {
- var hooks, ret,
+ var ret, hooks,
nType = elem.nodeType;
- // don't get/set attributes on text, comment and attribute nodes
+ // Don't get/set attributes on text, comment and attribute nodes
if ( nType === 3 || nType === 8 || nType === 2 ) {
return;
}
}
if ( value !== undefined ) {
-
if ( value === null ) {
jQuery.removeAttr( elem, name );
+ return;
+ }
- } else if ( hooks && "set" in hooks &&
- (ret = hooks.set( elem, value, name )) !== undefined ) {
-
+ if ( hooks && "set" in hooks &&
+ ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
return ret;
-
- } else {
- elem.setAttribute( name, value + "" );
- return value;
}
- } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
+ elem.setAttribute( name, value + "" );
+ return value;
+ }
+
+ if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
return ret;
+ }
- } else {
- ret = jQuery.find.attr( elem, name );
+ ret = jQuery.find.attr( elem, name );
- // Non-existent attributes return null, we normalize to undefined
- return ret == null ?
- undefined :
- ret;
+ // Non-existent attributes return null, we normalize to undefined
+ return ret == null ? undefined : ret;
+ },
+
+ attrHooks: {
+ type: {
+ set: function( elem, value ) {
+ if ( !support.radioValue && value === "radio" &&
+ jQuery.nodeName( elem, "input" ) ) {
+ var val = elem.value;
+ elem.setAttribute( "type", value );
+ if ( val ) {
+ elem.value = val;
+ }
+ return value;
+ }
+ }
}
},
attrNames = value && value.match( rnotwhite );
if ( attrNames && elem.nodeType === 1 ) {
- while ( (name = attrNames[i++]) ) {
+ while ( ( name = attrNames[i++] ) ) {
propName = jQuery.propFix[ name ] || name;
// Boolean attributes get special treatment (#10870)
if ( jQuery.expr.match.bool.test( name ) ) {
+
// Set corresponding property to false
elem[ propName ] = false;
}
elem.removeAttribute( name );
}
}
- },
-
- attrHooks: {
- type: {
- set: function( elem, value ) {
- if ( !support.radioValue && value === "radio" &&
- jQuery.nodeName( elem, "input" ) ) {
- var val = elem.value;
- elem.setAttribute( "type", value );
- if ( val ) {
- elem.value = val;
- }
- return value;
- }
- }
- }
}
});
define([
"../core",
"../core/access",
- "./support"
+ "./support",
+ "../selector"
], function( jQuery, access, support ) {
var rfocusable = /^(?:input|select|textarea|button)$/i;
});
jQuery.extend({
- propFix: {
- "for": "htmlFor",
- "class": "className"
- },
-
prop: function( elem, name, value ) {
- var ret, hooks, notxml,
+ var ret, hooks,
nType = elem.nodeType;
// Don't get/set properties on text, comment and attribute nodes
- if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
+ if ( nType === 3 || nType === 8 || nType === 2 ) {
return;
}
- notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
+ if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
- if ( notxml ) {
// Fix name and attach hooks
name = jQuery.propFix[ name ] || name;
hooks = jQuery.propHooks[ name ];
}
if ( value !== undefined ) {
- return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
- ret :
- ( elem[ name ] = value );
-
- } else {
- return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
- ret :
- elem[ name ];
+ if ( hooks && "set" in hooks &&
+ ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
+ return ret;
+ }
+
+ return ( elem[ name ] = value );
}
+
+ if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
+ return ret;
+ }
+
+ return elem[ name ];
},
propHooks: {
-1;
}
}
+ },
+
+ propFix: {
+ "for": "htmlFor",
+ "class": "className"
}
});