Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Patch for jQuery ticket #1954
diff --git a/src/attributes.js b/src/attributes.js
index fec1323..86b1e60 100644
--- a/src/attributes.js
+++ b/src/attributes.js
@@ -31,7 +31,11 @@ jQuery.fn.extend({
return this.each(function(){
jQuery.attr( this, name, "" );
if ( this.nodeType === 1 ) {
- this.removeAttribute( name );
+ if ( name === "value" && jQuery.nodeName( this, "button" ) && jQuery.browser.msie && parseInt(jQuery.browser.version, 10) <= 7 ) {
+ this.removeAttributeNode(this.getAttributeNode( name ));
+ } else {
+ this.removeAttribute( name );
+ }
}
});
},
@@ -206,6 +210,10 @@ jQuery.fn.extend({
return elem.getAttribute("value") === null ? "on" : elem.value;
}
+ if ( jQuery.nodeName( elem, "button" ) && jQuery.browser.msie && parseInt(jQuery.browser.version, 10) <= 7 ) {
+ return elem.getAttributeNode( "value" ) ? elem.getAttributeNode( "value" ).nodeValue : undefined;
+ }
+
// Everything else, we just grab the value
return (elem.value || "").replace(rreturn, "");
@@ -252,6 +260,17 @@ jQuery.fn.extend({
this.selectedIndex = -1;
}
+ } else if ( jQuery.nodeName( this, "button" ) && jQuery.browser.msie && parseInt(jQuery.browser.version, 10) <= 7 ) {
+ var attributeNode = this.getAttributeNode( "value" );
+
+ if (attributeNode) {
+ attributeNode.nodeValue = val;
+ } else {
+ attributeNode = document.createAttribute("value");
+ attributeNode.nodeValue = val;
+ this.setAttributeNode(attributeNode);
+ }
+
} else {
this.value = val;
}
@@ -318,7 +337,22 @@ jQuery.extend({
if ( value === null ) {
if ( elem.nodeType === 1 ) {
- elem.removeAttribute( name );
+ if ( name === "value" && jQuery.nodeName( elem, "button" ) && jQuery.browser.msie && parseInt(jQuery.browser.version, 10) <= 7 ) {
+ elem.removeAttributeNode(elem.getAttributeNode( name ));
+ } else {
+ elem.removeAttribute( name );
+ }
+ }
+
+ } else if ( name === "value" && jQuery.nodeName( elem, "button" ) && jQuery.browser.msie && parseInt(jQuery.browser.version, 10) <= 7 ) {
+ var attributeNode = elem.getAttributeNode( name );
+
+ if (attributeNode) {
+ attributeNode.nodeValue = value;
+ } else {
+ attributeNode = document.createAttribute("value");
+ attributeNode.nodeValue = value;
+ elem.setAttributeNode(attributeNode);
}
} else {
@@ -331,6 +365,10 @@ jQuery.extend({
return elem.getAttributeNode( name ).nodeValue;
}
+ if ( name === "value" && jQuery.nodeName( elem, "button" ) && jQuery.browser.msie && parseInt(jQuery.browser.version, 10) <= 7 ) {
+ return elem.getAttributeNode( name ) ? elem.getAttributeNode( name ).nodeValue : undefined;
+ }
+
// 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
You can’t perform that action at this time.