11define ( [
22 "../core" ,
3- "../var/rnotwhite" ,
3+ "../core/stripAndCollapse" ,
4+ "../var/rnothtmlwhite" ,
45 "../data/var/dataPriv" ,
56 "../core/init"
6- ] , function ( jQuery , rnotwhite , dataPriv ) {
7+ ] , function ( jQuery , stripAndCollapse , rnothtmlwhite , dataPriv ) {
78
89"use strict" ;
910
10- var rclass = / [ \t \r \n \f ] / g;
11-
1211function getClass ( elem ) {
1312 return elem . getAttribute && elem . getAttribute ( "class" ) || "" ;
1413}
@@ -25,12 +24,11 @@ jQuery.fn.extend( {
2524 }
2625
2726 if ( typeof value === "string" && value ) {
28- classes = value . match ( rnotwhite ) || [ ] ;
27+ classes = value . match ( rnothtmlwhite ) || [ ] ;
2928
3029 while ( ( elem = this [ i ++ ] ) ) {
3130 curValue = getClass ( elem ) ;
32- cur = elem . nodeType === 1 &&
33- ( " " + curValue + " " ) . replace ( rclass , " " ) ;
31+ cur = elem . nodeType === 1 && ( " " + stripAndCollapse ( curValue ) + " " ) ;
3432
3533 if ( cur ) {
3634 j = 0 ;
@@ -41,7 +39,7 @@ jQuery.fn.extend( {
4139 }
4240
4341 // Only assign if different to avoid unneeded rendering.
44- finalValue = jQuery . trim ( cur ) ;
42+ finalValue = stripAndCollapse ( cur ) ;
4543 if ( curValue !== finalValue ) {
4644 elem . setAttribute ( "class" , finalValue ) ;
4745 }
@@ -67,14 +65,13 @@ jQuery.fn.extend( {
6765 }
6866
6967 if ( typeof value === "string" && value ) {
70- classes = value . match ( rnotwhite ) || [ ] ;
68+ classes = value . match ( rnothtmlwhite ) || [ ] ;
7169
7270 while ( ( elem = this [ i ++ ] ) ) {
7371 curValue = getClass ( elem ) ;
7472
7573 // This expression is here for better compressibility (see addClass)
76- cur = elem . nodeType === 1 &&
77- ( " " + curValue + " " ) . replace ( rclass , " " ) ;
74+ cur = elem . nodeType === 1 && ( " " + stripAndCollapse ( curValue ) + " " ) ;
7875
7976 if ( cur ) {
8077 j = 0 ;
@@ -87,7 +84,7 @@ jQuery.fn.extend( {
8784 }
8885
8986 // Only assign if different to avoid unneeded rendering.
90- finalValue = jQuery . trim ( cur ) ;
87+ finalValue = stripAndCollapse ( cur ) ;
9188 if ( curValue !== finalValue ) {
9289 elem . setAttribute ( "class" , finalValue ) ;
9390 }
@@ -122,7 +119,7 @@ jQuery.fn.extend( {
122119 // Toggle individual class names
123120 i = 0 ;
124121 self = jQuery ( this ) ;
125- classNames = value . match ( rnotwhite ) || [ ] ;
122+ classNames = value . match ( rnothtmlwhite ) || [ ] ;
126123
127124 while ( ( className = classNames [ i ++ ] ) ) {
128125
@@ -165,10 +162,8 @@ jQuery.fn.extend( {
165162 className = " " + selector + " " ;
166163 while ( ( elem = this [ i ++ ] ) ) {
167164 if ( elem . nodeType === 1 &&
168- ( " " + getClass ( elem ) + " " ) . replace ( rclass , " " )
169- . indexOf ( className ) > - 1
170- ) {
171- return true ;
165+ ( " " + stripAndCollapse ( getClass ( elem ) ) + " " ) . indexOf ( className ) > - 1 ) {
166+ return true ;
172167 }
173168 }
174169
0 commit comments