@@ -71,31 +71,30 @@ jQuery.fn.extend({
71
71
} ,
72
72
73
73
removeClass : function ( value ) {
74
- var classNames , i , l , elem , className , c , cl ;
74
+ var removes , className , elem , c , cl , i , l ;
75
75
76
76
if ( jQuery . isFunction ( value ) ) {
77
77
return this . each ( function ( j ) {
78
78
jQuery ( this ) . removeClass ( value . call ( this , j , this . className ) ) ;
79
79
} ) ;
80
80
}
81
-
82
81
if ( ( value && typeof value === "string" ) || value === undefined ) {
83
- classNames = ( value || "" ) . split ( core_rspace ) ;
82
+ removes = ( value || "" ) . split ( core_rspace ) ;
84
83
85
84
for ( i = 0 , l = this . length ; i < l ; i ++ ) {
86
85
elem = this [ i ] ;
87
-
88
86
if ( elem . nodeType === 1 && elem . className ) {
89
- if ( value ) {
90
- className = ( " " + elem . className + " " ) . replace ( rclass , " " ) ;
91
- for ( c = 0 , cl = classNames . length ; c < cl ; c ++ ) {
92
- className = className . replace ( " " + classNames [ c ] + " " , " " ) ;
93
- }
94
- elem . className = jQuery . trim ( className ) ;
95
87
96
- } else {
97
- elem . className = "" ;
88
+ className = ( " " + elem . className + " " ) . replace ( rclass , " " ) ;
89
+
90
+ // loop over each item in the removal list
91
+ for ( c = 0 , cl = removes . length ; c < cl ; c ++ ) {
92
+ // Remove until there is nothing to remove,
93
+ while ( className . indexOf ( " " + removes [ c ] + " " ) > - 1 ) {
94
+ className = className . replace ( " " + removes [ c ] + " " , " " ) ;
95
+ }
98
96
}
97
+ elem . className = value ? jQuery . trim ( className ) : "" ;
99
98
}
100
99
}
101
100
}
0 commit comments