aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/attributes.js21
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