@@ -153,7 +153,10 @@ export class Checkbox implements ComponentInterface {
153153
154154 // Watch for class changes to update validation state.
155155 if ( Build . isBrowser && typeof MutationObserver !== 'undefined' ) {
156- this . validationObserver = new MutationObserver ( ( ) => {
156+ this . validationObserver = new MutationObserver ( ( mutations ) => {
157+ if ( mutations . some ( ( mutation ) => mutation . type === 'characterData' ) ) {
158+ this . hasLabelContent = this . el . textContent !== '' ;
159+ }
157160 const newIsInvalid = checkInvalidState ( el ) ;
158161 if ( this . isInvalid !== newIsInvalid ) {
159162 this . isInvalid = newIsInvalid ;
@@ -184,11 +187,14 @@ export class Checkbox implements ComponentInterface {
184187 this . validationObserver . observe ( el , {
185188 attributes : true ,
186189 attributeFilter : [ 'class' ] ,
190+ characterData : true ,
191+ subtree : true ,
187192 } ) ;
188193 }
189194
190195 // Always set initial state
191196 this . isInvalid = checkInvalidState ( el ) ;
197+ this . hasLabelContent = this . el . textContent !== '' ;
192198 }
193199
194200 componentWillLoad ( ) {
@@ -267,10 +273,6 @@ export class Checkbox implements ComponentInterface {
267273 ev . stopPropagation ( ) ;
268274 } ;
269275
270- private onSlotChange = ( ) => {
271- this . hasLabelContent = this . el . textContent !== '' ;
272- } ;
273-
274276 private getHintTextId ( ) : string | undefined {
275277 const { helperText, errorText, helperTextId, errorTextId, isInvalid } = this ;
276278
@@ -387,7 +389,7 @@ export class Checkbox implements ComponentInterface {
387389 id = { this . inputLabelId }
388390 onClick = { this . onDivLabelClick }
389391 >
390- < slot onSlotchange = { this . onSlotChange } > </ slot >
392+ < slot > </ slot >
391393 { this . renderHintText ( ) }
392394 </ div >
393395 < div class = "native-wrapper" >
0 commit comments