Skip to content

Commit

Permalink
refactor(helpers): replace addEventListener with inline listener
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Jun 1, 2024
1 parent 44a40d0 commit f5a27f8
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/helpers/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ export function addEventListeners(callback: () => void) {
'main button',
) as NodeListOf<HTMLButtonElement>

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)
}
})
}

0 comments on commit f5a27f8

Please sign in to comment.