From f5a27f87f59c700de1a263832ef9cceeada228f4 Mon Sep 17 00:00:00 2001 From: Mark Date: Sat, 1 Jun 2024 11:56:48 -0400 Subject: [PATCH] refactor(helpers): replace `addEventListener` with inline listener --- src/helpers/events.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/helpers/events.ts b/src/helpers/events.ts index 9fb19fb..1740a1a 100644 --- a/src/helpers/events.ts +++ b/src/helpers/events.ts @@ -10,12 +10,10 @@ export function addEventListeners(callback: () => void) { 'main button', ) as NodeListOf - buttons.forEach((oldButton) => { - const newButton = oldButton.cloneNode(true) as HTMLButtonElement - newButton.addEventListener('click', () => { + buttons.forEach((button) => { + button.onclick = () => { audio.play() callback() - }) - oldButton.parentNode?.replaceChild(newButton, oldButton) + } }) }