@@ -914,6 +914,23 @@ describe('jqLite', function() {
914
914
} ) ;
915
915
916
916
917
+ // JQLite specific implementation/performance tests
918
+ if ( _jqLiteMode ) {
919
+ it ( 'should only get/set the attribute once when multiple classes added' , function ( ) {
920
+ var fakeElement = {
921
+ nodeType : 1 ,
922
+ setAttribute : jasmine . createSpy ( ) ,
923
+ getAttribute : jasmine . createSpy ( ) . and . returnValue ( '' )
924
+ } ;
925
+ var jqA = jqLite ( fakeElement ) ;
926
+
927
+ jqA . addClass ( 'foo bar baz' ) ;
928
+ expect ( fakeElement . getAttribute ) . toHaveBeenCalledOnceWith ( 'class' ) ;
929
+ expect ( fakeElement . setAttribute ) . toHaveBeenCalledOnceWith ( 'class' , 'foo bar baz' ) ;
930
+ } ) ;
931
+ }
932
+
933
+
917
934
it ( 'should not add duplicate classes' , function ( ) {
918
935
var jqA = jqLite ( a ) ;
919
936
expect ( a . className ) . toBe ( '' ) ;
@@ -1031,6 +1048,23 @@ describe('jqLite', function() {
1031
1048
jqA . removeClass ( 'foo baz noexistent' ) ;
1032
1049
expect ( a . className ) . toBe ( 'bar' ) ;
1033
1050
} ) ;
1051
+
1052
+
1053
+ // JQLite specific implementation/performance tests
1054
+ if ( _jqLiteMode ) {
1055
+ it ( 'should get/set the attribute once when removing multiple classes' , function ( ) {
1056
+ var fakeElement = {
1057
+ nodeType : 1 ,
1058
+ setAttribute : jasmine . createSpy ( ) ,
1059
+ getAttribute : jasmine . createSpy ( ) . and . returnValue ( 'foo bar baz' )
1060
+ } ;
1061
+ var jqA = jqLite ( fakeElement ) ;
1062
+
1063
+ jqA . removeClass ( 'foo baz noexistent' ) ;
1064
+ expect ( fakeElement . getAttribute ) . toHaveBeenCalledOnceWith ( 'class' ) ;
1065
+ expect ( fakeElement . setAttribute ) . toHaveBeenCalledOnceWith ( 'class' , 'bar' ) ;
1066
+ } ) ;
1067
+ }
1034
1068
} ) ;
1035
1069
} ) ;
1036
1070
0 commit comments