aboutsummaryrefslogtreecommitdiffstats
path: root/src/attributes.js
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2010-09-28 11:12:13 -0400
committerJohn Resig <jeresig@gmail.com>2010-09-28 11:12:13 -0400
commitc7c067723006b0dfbb123c1a36885580a587d091 (patch)
tree28cf6c09f7f970792ffe7dfd2ca9257fc476f0e5 /src/attributes.js
parentcf672a2e7a886cac5ae62f6772c6b4b43b19a2fc (diff)
downloadjquery-c7c067723006b0dfbb123c1a36885580a587d091.tar.gz
jquery-c7c067723006b0dfbb123c1a36885580a587d091.zip
Make .attr(name, null) equivalent to removeAttr(name). (Was roughly this before - but is now consistent across platforms). Fixes #6341.
Diffstat (limited to 'src/attributes.js')
-rw-r--r--src/attributes.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/attributes.js b/src/attributes.js
index cb9f2cf5e..ec4841bd3 100644
--- a/src/attributes.js
+++ b/src/attributes.js
@@ -295,7 +295,14 @@ jQuery.extend({
jQuery.error( "type property can't be changed" );
}
- elem[ name ] = value;
+ if ( value === null ) {
+ if ( elem.nodeType === 1 ) {
+ elem.removeAttribute( name );
+ }
+
+ } else {
+ elem[ name ] = value;
+ }
}
// browsers index elements by id/name on forms, give priority to attributes.