Skip to content

Commit

Permalink
Fix removeEventListener calls (#60)
Browse files Browse the repository at this point in the history
I spotted an error in the console, which lead to a TIL.

`removeEventListener` needs to have the same arguments passed to `addEventListener` to work.

So this fixes those calls and the thrown error.
  • Loading branch information
kaspth authored Mar 27, 2023
1 parent 9c60662 commit 2ba7ece
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/assets/javascripts/showcase.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ window.customElements.define("showcase-sample", class extends HTMLElement {
}

disconnectedCallback() {
this.events.forEach(this.removeEventListener)
this.events.forEach((name) => this.removeEventListener(name, this.emit))
}

emit(event) {
Expand Down

0 comments on commit 2ba7ece

Please sign in to comment.