File tree Expand file tree Collapse file tree 1 file changed +10
-11
lines changed
Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -1814,20 +1814,19 @@ export async function afterTestWordChange(
18141814 //
18151815 } else if ( direction === "back" ) {
18161816 if ( Config . mode === "zen" ) {
1817- const wordsChildren = [ ... ( wordsEl . children ?? [ ] ) ] as HTMLElement [ ] ;
1818-
1817+ // because we need to delete newline, beforenewline and afternewline elements which dont have wordindex attributes
1818+ // we need to do this loop thingy and delete all elements after the active word
18191819 let deleteElements = false ;
1820- for ( const child of wordsChildren ) {
1821- if (
1822- ! deleteElements &&
1823- parseInt ( child . getAttribute ( "data-wordindex" ) ?? "-1" , 10 ) ===
1824- TestState . activeWordIndex
1825- ) {
1826- deleteElements = true ;
1827- continue ;
1828- }
1820+ for ( const child of wordsEl . children ) {
18291821 if ( deleteElements ) {
18301822 child . remove ( ) ;
1823+ continue ;
1824+ }
1825+ const attr = child . getAttribute ( "data-wordindex" ) ;
1826+ if ( attr === null ) continue ;
1827+ const wordIndex = parseInt ( attr , 10 ) ;
1828+ if ( wordIndex === TestState . activeWordIndex ) {
1829+ deleteElements = true ;
18311830 }
18321831 }
18331832 }
You can’t perform that action at this time.
0 commit comments