@@ -194,7 +194,11 @@ async function app() {
194194 } ;
195195 const $main = $ ( 'main' ) ;
196196 const themeToggle = $ ( '[data-action="toggleTheme"]' ) ;
197- const cleanAttempts = $ ( 'main .attempts' ) . innerHTML ;
197+ const $attempts = $ ( 'main .attempts' ) ;
198+ const $keyboard = $ ( '.keyboard' , $main ) ;
199+
200+ const cleanKeyboard = $keyboard . innerHTML ;
201+ const cleanAttempts = $attempts . innerHTML ;
198202
199203 const THEME_KEY = 'sordle-theme' ;
200204 const getInitialTheme = ( ) => {
@@ -307,10 +311,8 @@ async function app() {
307311 } ;
308312
309313 const rippleKeyboard = ( ) => {
310- const keyboard = $ ( '.keyboard' , $main ) ;
311- if ( ! keyboard ) return ;
312- const keys = $$ ( 'button' , keyboard ) ;
313- const rect = keyboard . getBoundingClientRect ( ) ;
314+ const keys = $$ ( 'button' , $keyboard ) ;
315+ const rect = $keyboard . getBoundingClientRect ( ) ;
314316 const cx = rect . left + rect . width / 2 ;
315317 const cy = rect . top + rect . height / 2 ;
316318 let max = 1 ;
@@ -323,9 +325,9 @@ async function app() {
323325 keys . forEach ( ( key , i ) => {
324326 key . style . setProperty ( '--ripple-delay' , `${ Math . round ( ( distances [ i ] / max ) * 260 ) } ms` ) ;
325327 } ) ;
326- keyboard . classList . remove ( 'ripple' ) ;
327- void keyboard . offsetWidth ;
328- keyboard . classList . add ( 'ripple' ) ;
328+ $ keyboard. classList . remove ( 'ripple' ) ;
329+ void $ keyboard. offsetWidth ;
330+ $ keyboard. classList . add ( 'ripple' ) ;
329331 } ;
330332
331333 // Celebration: launch confetti up and inward from both bottom corners.
@@ -594,7 +596,8 @@ async function app() {
594596
595597 const clearGame = ( ) => {
596598 localStorage . removeItem ( SAVE_KEY ) ;
597- $ ( 'main .attempts' ) . innerHTML = cleanAttempts ;
599+ $attempts . innerHTML = cleanAttempts ;
600+ $keyboard . innerHTML = cleanKeyboard ;
598601 } ;
599602
600603 const setKeyColor = ( char : string , color : Status ) => {
0 commit comments