diff options
author | Richard Gibson <richard.gibson@gmail.com> | 2012-11-27 09:46:06 -0500 |
---|---|---|
committer | Richard Gibson <richard.gibson@gmail.com> | 2012-11-27 09:46:06 -0500 |
commit | 243d4cc83cf15f30db1e09d9374c265a1513b18d (patch) | |
tree | 51c0cc1fe4baa08a64e53e48b9952e5d8585fd72 /src/attributes.js | |
parent | b9dfcfd7362825ccda0ca4ea96d385b0c6ae522d (diff) | |
download | jquery-243d4cc83cf15f30db1e09d9374c265a1513b18d.tar.gz jquery-243d4cc83cf15f30db1e09d9374c265a1513b18d.zip |
Don't let removeClass create attributes
Diffstat (limited to 'src/attributes.js')
-rw-r--r-- | src/attributes.js | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/attributes.js b/src/attributes.js index ac4b3c866..bc065481c 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -51,11 +51,12 @@ jQuery.fn.extend({ for ( ; i < len; i++ ) { elem = this[ i ]; + cur = elem.nodeType === 1 && ( elem.className ? + ( " " + elem.className + " " ).replace( rclass, " " ) : + " " + ); - if ( elem.nodeType === 1 ) { - cur = elem.className ? - ( " " + elem.className + " " ).replace( rclass, " " ) : - " "; + if ( cur ) { j = 0; while ( (clazz = classes[j++]) ) { if ( cur.indexOf( " " + clazz + " " ) < 0 ) { @@ -87,11 +88,13 @@ jQuery.fn.extend({ for ( ; i < len; i++ ) { elem = this[ i ]; - if ( elem.nodeType === 1 ) { - // This expression is here for better compressibility (see addClass) - cur = elem.className ? - ( " " + elem.className + " " ).replace( rclass, " " ) : - " "; + // This expression is here for better compressibility (see addClass) + cur = elem.nodeType === 1 && ( elem.className ? + ( " " + elem.className + " " ).replace( rclass, " " ) : + "" + ); + + if ( cur ) { j = 0; while ( (clazz = classes[j++]) ) { // Remove *all* instances |