diff options
author | timmywil <tim.willison@thisismedium.com> | 2011-04-19 13:17:38 -0400 |
---|---|---|
committer | timmywil <tim.willison@thisismedium.com> | 2011-04-19 13:17:38 -0400 |
commit | 825d3d96cebf9a88f34411a2df95622fd3e32619 (patch) | |
tree | d18c9ef9b1d0e8a551457a9ccd3e7774bba81a74 | |
parent | 3a3842c6696f121392c89b68f2f061043405ae9f (diff) | |
download | jquery-825d3d96cebf9a88f34411a2df95622fd3e32619.tar.gz jquery-825d3d96cebf9a88f34411a2df95622fd3e32619.zip |
Only use getAttributeNode on buttons when setting value
-rw-r--r-- | src/attributes.js | 3 | ||||
-rw-r--r-- | test/unit/attributes.js | 3 |
2 files changed, 5 insertions, 1 deletions
diff --git a/src/attributes.js b/src/attributes.js index 794b98d75..d163469c7 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -435,6 +435,9 @@ if ( !jQuery.support.getSetAttribute ) { // And the name attribute formHook = jQuery.attrHooks.name = jQuery.attrHooks.value = jQuery.valHooks.button = { get: function( elem, name ) { + if ( name === "value" && !jQuery.nodeName( elem, "button" ) ) { + return elem.getAttribute( name ); + } var ret = elem.getAttributeNode( name ); // Return undefined if not specified instead of empty string return ret && ret.specified ? diff --git a/test/unit/attributes.js b/test/unit/attributes.js index 80ccf71a8..f663e443e 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -77,7 +77,7 @@ test("prop(String, Object)", function() { }); test("attr(String)", function() { - expect(34); + expect(35); equals( jQuery("#text1").attr("type"), "text", "Check for type attribute" ); equals( jQuery("#radio1").attr("type"), "radio", "Check for type attribute" ); @@ -90,6 +90,7 @@ test("attr(String)", function() { equals( jQuery("#name").attr("name"), "name", "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" ); + equals( jQuery("#text1").attr("value", "t").attr("value"), "t", "Check setting the value attribute" ); 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" ); |