Skip to content

Instantly share code, notes, and snippets.

Created February 27, 2011 01:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/845799 to your computer and use it in GitHub Desktop.
Save anonymous/845799 to your computer and use it in GitHub Desktop.
Patch for jQuery ticket #1954 (reading only)
diff --git a/src/attributes.js b/src/attributes.js
index 5997210..1d1fcf8 100644
--- a/src/attributes.js
+++ b/src/attributes.js
@@ -211,6 +211,10 @@ jQuery.fn.extend({
return elem.getAttribute("value") === null ? "on" : elem.value;
}
+ if ( jQuery.nodeName( elem, "button" ) ) {
+ return elem.getAttributeNode( "value" ) ? elem.getAttributeNode( "value" ).nodeValue : "";
+ }
+
// Everything else, we just grab the value
return (elem.value || "").replace(rreturn, "");
@@ -336,6 +340,10 @@ jQuery.extend({
return elem.getAttributeNode( name ).nodeValue;
}
+ if ( name === "value" && jQuery.nodeName( elem, "button" ) ) {
+ return elem.getAttributeNode( name ) ? elem.getAttributeNode( name ).nodeValue : "";
+ }
+
// elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
// http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
if ( name === "tabIndex" ) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment