Skip to content
Permalink
Browse files
Only use getAttributeNode on buttons when setting value
  • Loading branch information
timmywil committed Apr 19, 2011
1 parent 3a3842c commit 825d3d9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
@@ -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" ) ) {

This comment has been minimized.

Copy link
@jdalton

jdalton Apr 19, 2011

Member

Don't yall have a support key for that button bug? If so it's only needed when buggy.

This comment has been minimized.

Copy link
@timmywil

timmywil Apr 19, 2011

Member

It fails because support.getSetAttribute is false, which is where this hook is being added so this won't be present in browsers that don't have the button problem.

This comment has been minimized.

Copy link
@jdalton

jdalton Apr 19, 2011

Member

Ah cool. Thanks for the context.

return elem.getAttribute( name );
}
var ret = elem.getAttributeNode( name );
// Return undefined if not specified instead of empty string
return ret && ret.specified ?
@@ -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" );

1 comment on commit 825d3d9

@timmywil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should say "getting" value.

Please sign in to comment.