File tree 2 files changed +10
-0
lines changed
2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -351,6 +351,9 @@ function hasClassWithNative_(element, className) {
351
351
* @private
352
352
*/
353
353
function hasClassWithoutNative_ ( element , className ) {
354
+ if ( className . indexOf ( ' ' ) >= 0 ) {
355
+ throw new Error ( `White spaces are not allowed. ('${ className } ')` ) ;
356
+ }
354
357
return ( ` ${ element . className } ` ) . indexOf ( ` ${ className } ` ) >= 0 ;
355
358
}
356
359
Original file line number Diff line number Diff line change @@ -66,6 +66,13 @@ describe('dom', function() {
66
66
assert . ok ( ! dom . hasClass ( element , 'class3' ) ) ;
67
67
} ) ;
68
68
69
+ it ( 'should throw an error if white spaces are used in the class name' , function ( ) {
70
+ var element = document . createElement ( 'div' ) ;
71
+ dom . addClasses ( element , 'class1 class2' ) ;
72
+
73
+ assert . throws ( ( ) => dom . hasClass ( element , 'class1 class2' ) ) ;
74
+ } ) ;
75
+
69
76
it ( 'should check if css classes are being removed' , function ( ) {
70
77
var element = document . createElement ( 'div' ) ;
71
78
dom . addClasses ( element , 'class1 class2' ) ;
You can’t perform that action at this time.
0 commit comments