Commit ba90af0d authored by timmywil's avatar timmywil

Make the value hook less obtrusive for elements which do not inherently have a...

Make the value hook less obtrusive for elements which do not inherently have a value property. Fixes #9328.
parent 7d3ba9f8
...@@ -498,7 +498,9 @@ jQuery.attrHooks.value = { ...@@ -498,7 +498,9 @@ jQuery.attrHooks.value = {
if ( formHook && jQuery.nodeName( elem, "button" ) ) { if ( formHook && jQuery.nodeName( elem, "button" ) ) {
return formHook.get( elem, name ); return formHook.get( elem, name );
} }
return elem.value; return name in elem ?
elem.value :
elem.getAttribute( name );
}, },
set: function( elem, value, name ) { set: function( elem, value, name ) {
if ( formHook && jQuery.nodeName( elem, "button" ) ) { if ( formHook && jQuery.nodeName( elem, "button" ) ) {
......
...@@ -40,7 +40,7 @@ test("jQuery.attrFix/jQuery.propFix integrity test", function() { ...@@ -40,7 +40,7 @@ test("jQuery.attrFix/jQuery.propFix integrity test", function() {
}); });
test("attr(String)", function() { test("attr(String)", function() {
expect(42); expect(43);
equals( jQuery("#text1").attr("type"), "text", "Check for type attribute" ); equals( jQuery("#text1").attr("type"), "text", "Check for type attribute" );
equals( jQuery("#radio1").attr("type"), "radio", "Check for type attribute" ); equals( jQuery("#radio1").attr("type"), "radio", "Check for type attribute" );
...@@ -54,6 +54,7 @@ test("attr(String)", function() { ...@@ -54,6 +54,7 @@ test("attr(String)", function() {
equals( jQuery("#text1").attr("name"), "action", "Check for name attribute" ); equals( jQuery("#text1").attr("name"), "action", "Check for name attribute" );
ok( jQuery("#form").attr("action").indexOf("formaction") >= 0, "Check for action attribute" ); ok( jQuery("#form").attr("action").indexOf("formaction") >= 0, "Check for action attribute" );
equals( jQuery("#text1").attr("value", "t").attr("value"), "t", "Check setting the value attribute" ); equals( jQuery("#text1").attr("value", "t").attr("value"), "t", "Check setting the value attribute" );
equals( jQuery("<div value='t'></div>").attr("value"), "t", "Check setting custom attr named 'value' on a div" );
equals( jQuery("#form").attr("blah", "blah").attr("blah"), "blah", "Set non-existant attribute on a form" ); equals( jQuery("#form").attr("blah", "blah").attr("blah"), "blah", "Set non-existant attribute on a form" );
equals( jQuery("#foo").attr("height"), undefined, "Non existent height attribute should return undefined" ); equals( jQuery("#foo").attr("height"), undefined, "Non existent height attribute should return undefined" );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment