@@ -108,23 +108,23 @@ export default class TranscriptionBlock extends HTMLElement {
108108 const nextPageButton = this . shadowRoot . querySelector ( '.next-page-button' )
109109 const inputField = this . shadowRoot . querySelector ( '.transcription-input' )
110110
111- // Shadow DOM element listeners (cleaned up when shadow DOM is replaced)
111+ // Shadow DOM element listeners
112112 if ( prevButton ) {
113- prevButton . addEventListener ( 'click' , this . moveToPreviousLine . bind ( this ) )
113+ this . cleanup . onElement ( prevButton , 'click' , this . moveToPreviousLine . bind ( this ) )
114114 }
115115 if ( prevPageButton ) {
116- prevPageButton . addEventListener ( 'click' , ( ) => this . navigateToPage ( 'prev' ) )
116+ this . cleanup . onElement ( prevPageButton , 'click' , ( ) => this . navigateToPage ( 'prev' ) )
117117 }
118118 if ( nextButton ) {
119- nextButton . addEventListener ( 'click' , this . moveToNextLine . bind ( this ) )
119+ this . cleanup . onElement ( nextButton , 'click' , this . moveToNextLine . bind ( this ) )
120120 }
121121 if ( nextPageButton ) {
122- nextPageButton . addEventListener ( 'click' , ( ) => this . navigateToPage ( 'next' ) )
122+ this . cleanup . onElement ( nextPageButton , 'click' , ( ) => this . navigateToPage ( 'next' ) )
123123 }
124124 if ( inputField ) {
125- inputField . addEventListener ( 'blur' , ( ) => this . checkDirtyLines ( ) )
126- inputField . addEventListener ( 'keydown' , ( e ) => this . handleKeydown ( e ) )
127- inputField . addEventListener ( 'input' , ( ) => {
125+ this . cleanup . onElement ( inputField , 'blur' , ( ) => this . checkDirtyLines ( ) )
126+ this . cleanup . onElement ( inputField , 'keydown' , ( e ) => this . handleKeydown ( e ) )
127+ this . cleanup . onElement ( inputField , 'input' , ( ) => {
128128 this . #transcriptions[ TPEN . activeLineIndex ] = inputField . value ?? ''
129129 this . markLineDirty ( TPEN . activeLineIndex )
130130 this . persistDraft ( TPEN . activeLineIndex )
0 commit comments