11import { dedupeMixin } from '@lion/core' ;
2- import { CssClassMixin } from '@lion/core/src/CssClassMixin.js' ;
32import { ObserverMixin } from '@lion/core/src/ObserverMixin.js' ;
43import { Unparseable } from '@lion/validate' ;
54
@@ -15,7 +14,7 @@ import { Unparseable } from '@lion/validate';
1514export const InteractionStateMixin = dedupeMixin (
1615 superclass =>
1716 // eslint-disable-next-line no-unused-vars, no-shadow
18- class InteractionStateMixin extends CssClassMixin ( ObserverMixin ( superclass ) ) {
17+ class InteractionStateMixin extends ObserverMixin ( superclass ) {
1918 static get properties ( ) {
2019 return {
2120 ...super . properties ,
@@ -24,15 +23,15 @@ export const InteractionStateMixin = dedupeMixin(
2423 */
2524 touched : {
2625 type : Boolean ,
27- nonEmptyToClass : 'state-touched' ,
26+ reflect : true ,
2827 } ,
2928
3029 /**
3130 * True when user has typed in something in the input field.
3231 */
3332 dirty : {
3433 type : Boolean ,
35- nonEmptyToClass : 'state-dirty' ,
34+ reflect : true ,
3635 } ,
3736
3837 /**
@@ -101,6 +100,17 @@ export const InteractionStateMixin = dedupeMixin(
101100 this . removeEventListener ( this . _valueChangedEvent , this . _iStateOnValueChange ) ;
102101 }
103102
103+ updated ( changedProperties ) {
104+ super . updated ( changedProperties ) ;
105+ // classes are added only for backward compatibility - they are deprecated
106+ if ( changedProperties . has ( 'touched' ) ) {
107+ this . classList [ this . touched ? 'add' : 'remove' ] ( 'state-touched' ) ;
108+ }
109+ if ( changedProperties . has ( 'dirty' ) ) {
110+ this . classList [ this . dirty ? 'add' : 'remove' ] ( 'state-dirty' ) ;
111+ }
112+ }
113+
104114 /**
105115 * Evaluations performed on connectedCallback. Since some components can be out of sync
106116 * (due to interdependence on light children that can only be processed
0 commit comments