77 minErr ,
88 trim ,
99 directiveNormalize ,
10+ hasAnimate ,
1011} from "../../shared/utils.js" ;
1112import { ALIASED_ATTR } from "../../shared/constants.js" ;
1213
@@ -75,7 +76,11 @@ export class Attributes {
7576 */
7677 $addClass ( classVal ) {
7778 if ( classVal && classVal . length > 0 ) {
78- this . $animate . addClass ( this . $$element , classVal ) ;
79+ if ( hasAnimate ( this . $$element [ 0 ] ) ) {
80+ this . $animate . addClass ( this . $$element , classVal ) ;
81+ } else {
82+ this . $$element [ 0 ] . classList . add ( classVal ) ;
83+ }
7984 }
8085 }
8186
@@ -87,7 +92,11 @@ export class Attributes {
8792 */
8893 $removeClass ( classVal ) {
8994 if ( classVal && classVal . length > 0 ) {
90- this . $animate . removeClass ( this . $$element , classVal ) ;
95+ if ( hasAnimate ( this . $$element [ 0 ] ) ) {
96+ this . $animate . removeClass ( this . $$element , classVal ) ;
97+ } else {
98+ this . $$element [ 0 ] . classList . remove ( classVal ) ;
99+ }
91100 }
92101 }
93102
@@ -101,12 +110,20 @@ export class Attributes {
101110 $updateClass ( newClasses , oldClasses ) {
102111 const toAdd = tokenDifference ( newClasses , oldClasses ) ;
103112 if ( toAdd && toAdd . length ) {
104- this . $animate . addClass ( this . $$element , toAdd ) ;
113+ if ( hasAnimate ( this . $$element [ 0 ] ) ) {
114+ this . $animate . addClass ( this . $$element , toAdd ) ;
115+ } else {
116+ this . $$element [ 0 ] . classList . add ( ...toAdd . split ( / \s + / ) ) ;
117+ }
105118 }
106119
107120 const toRemove = tokenDifference ( oldClasses , newClasses ) ;
108121 if ( toRemove && toRemove . length ) {
109- this . $animate . removeClass ( this . $$element , toRemove ) ;
122+ if ( hasAnimate ( this . $$element [ 0 ] ) ) {
123+ this . $animate . removeClass ( this . $$element , toRemove ) ;
124+ } else {
125+ this . $$element [ 0 ] . classList . remove ( ...toRemove . split ( / \s + / ) ) ;
126+ }
110127 }
111128 }
112129
0 commit comments