@@ -293,6 +293,7 @@ export const DashboardItemMixin = (superClass) =>
293
293
super ( ) ;
294
294
this . __keyboardController = new KeyboardController ( this ) ;
295
295
this . __focusTrapController = new FocusTrapController ( this ) ;
296
+ this . __boundRootHeadingLevelChangedListener = this . __updateRootHeadingLevel . bind ( this ) ;
296
297
}
297
298
298
299
/** @protected */
@@ -401,19 +402,22 @@ export const DashboardItemMixin = (superClass) =>
401
402
this . __removeHeadingLevelObserver ( ) ;
402
403
const parentLayout = getParentLayout ( this ) ;
403
404
if ( parentLayout ) {
404
- this . __headingLevelObserver = new MutationObserver ( ( ) => this . __updateRootHeadingLevel ( ) ) ;
405
- this . __headingLevelObserver . observe ( parentLayout , {
406
- attributes : true ,
407
- attributeFilter : [ 'root-heading-level' ] ,
408
- } ) ;
405
+ this . __rootHeadingLevelListenerTarget = parentLayout ;
406
+ parentLayout . addEventListener (
407
+ 'dashboard-root-heading-level-changed' ,
408
+ this . __boundRootHeadingLevelChangedListener ,
409
+ ) ;
409
410
}
410
411
}
411
412
412
413
/** @private */
413
414
__removeHeadingLevelObserver ( ) {
414
- if ( this . __headingLevelObserver ) {
415
- this . __headingLevelObserver . disconnect ( ) ;
416
- this . __headingLevelObserver = null ;
415
+ if ( this . __rootHeadingLevelListenerTarget ) {
416
+ this . __rootHeadingLevelListenerTarget . removeEventListener (
417
+ 'dashboard-root-heading-level-changed' ,
418
+ this . __boundRootHeadingLevelChangedListener ,
419
+ ) ;
420
+ this . __rootHeadingLevelListenerTarget = null ;
417
421
}
418
422
}
419
423
0 commit comments