Remove value check from formHook; other elements can use value hook

This commit is contained in:
timmywil 2011-05-07 22:01:10 -04:00
parent 90f37aaf7a
commit 18b1cf2942
2 changed files with 3 additions and 4 deletions

View file

@ -495,9 +495,6 @@ if ( !jQuery.support.getSetAttribute ) {
formHook = jQuery.attrHooks.name = jQuery.attrHooks.value = jQuery.valHooks.button = { formHook = jQuery.attrHooks.name = jQuery.attrHooks.value = jQuery.valHooks.button = {
get: function( elem, name ) { get: function( elem, name ) {
var ret; var ret;
if ( name === "value" && !jQuery.nodeName( elem, "button" ) ) {
return elem.getAttribute( name );
}
ret = elem.getAttributeNode( name ); ret = elem.getAttributeNode( name );
// Return undefined if nodeValue is empty string // Return undefined if nodeValue is empty string
return ret && ret.nodeValue !== "" ? return ret && ret.nodeValue !== "" ?

View file

@ -144,7 +144,7 @@ test("attr(Hash)", function() {
}); });
test("attr(String, Object)", function() { test("attr(String, Object)", function() {
expect(58); expect(59);
var div = jQuery("div").attr("foo", "bar"), var div = jQuery("div").attr("foo", "bar"),
fail = false; fail = false;
@ -244,6 +244,8 @@ test("attr(String, Object)", function() {
table.attr("cellspacing", "2"); table.attr("cellspacing", "2");
equals( table[0].cellSpacing, "2", "Check cellspacing is correctly set" ); equals( table[0].cellSpacing, "2", "Check cellspacing is correctly set" );
equals( jQuery("#area1").attr("value"), undefined, "Value attribute retrieved correctly on textarea." );
// for #1070 // for #1070
jQuery("#name").attr("someAttr", "0"); jQuery("#name").attr("someAttr", "0");
equals( jQuery("#name").attr("someAttr"), "0", "Set attribute to a string of \"0\"" ); equals( jQuery("#name").attr("someAttr"), "0", "Set attribute to a string of \"0\"" );