aboutsummaryrefslogtreecommitdiffstats
path: root/src/attributes.js
diff options
context:
space:
mode:
authortimmywil <tim.willison@thisismedium.com>2011-04-02 14:23:33 -0400
committertimmywil <tim.willison@thisismedium.com>2011-04-03 19:13:41 -0400
commitff7576755864193b4c1a00464bf0919bbbe96e8b (patch)
treec65fe32f5b98d85ac267c38dbd17861246ee3db3 /src/attributes.js
parent8cbf551a48cbc47eccba2050e95745f70166ae1d (diff)
downloadjquery-ff7576755864193b4c1a00464bf0919bbbe96e8b.tar.gz
jquery-ff7576755864193b4c1a00464bf0919bbbe96e8b.zip
Minor adjustments and cleanup, including normalizing the value to a string when setting( list of changes below )
- Normalize set value to string to synchronize return type cross-browser - Add style attrHook to propHooks to support style getting in all browsers for both attr and prop - Extend the selected propHook instead of overriding a possible set function - Remove selected propHook TODO since there is no selected content attribute and it should return null
Diffstat (limited to 'src/attributes.js')
-rw-r--r--src/attributes.js23
1 files changed, 7 insertions, 16 deletions
diff --git a/src/attributes.js b/src/attributes.js
index 5afcffce3..7c03cddbe 100644
--- a/src/attributes.js
+++ b/src/attributes.js
@@ -313,7 +313,7 @@ jQuery.extend({
return ret;
} else {
- elem.setAttribute( name, value );
+ elem.setAttribute( name, "" + value );
return value;
}
@@ -440,10 +440,8 @@ if ( !jQuery.support.getSetAttribute ) {
var ret = elem.getAttributeNode( name );
if ( ret ) {
ret.nodeValue = value;
- } else {
- elem.setAttribute( name, value );
+ return value;
}
- return value;
}
};
}
@@ -458,9 +456,6 @@ jQuery.each([ "selected", "checked", "readonly", "disabled" ], function( i, name
jQuery.removeAttr( elem, name );
return false;
}
-
- elem.setAttribute( name, value );
- return value;
}
});
});
@@ -477,7 +472,7 @@ if ( !jQuery.support.hrefNormalized ) {
}
if ( !jQuery.support.style ) {
- jQuery.attrHooks.style = {
+ jQuery.propHooks.style = jQuery.attrHooks.style = {
get: function( elem ) {
return elem.style.cssText;
},
@@ -490,24 +485,20 @@ 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 = {
+ jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
get: function( elem ) {
var parent = elem.parentNode;
-
+
if ( parent ) {
parent.selectedIndex;
-
- // TODO: We may need an attrHook for selected that simply defers to prop?
- // The attr is undefined if the option is created with createElement and not on the DOM
-
+
// Make sure that it also works with optgroups, see #5701
if ( parent.parentNode ) {
parent.parentNode.selectedIndex;
}
}
}
- };
+ });
}
})( jQuery ); \ No newline at end of file