Define function as member arrow function

This way it behaves as an instance method, and we don't have to pass in the object.
This commit is contained in:
David Cook
2026-04-01 11:08:54 +11:00
parent 6013b6be70
commit 6048fcb053

View File

@@ -8,7 +8,7 @@ export default class extends Controller {
window.addEventListener("click", this.#hideIfClickedOutside);
// Close menu when making a selection
this.contentTarget.addEventListener("click", this.#selected.bind(this));
this.contentTarget.addEventListener("click", this.#selected);
}
disconnect() {
@@ -19,7 +19,7 @@ export default class extends Controller {
this.#toggleShow();
}
#selected() {
#selected = () => {
this.contentTarget.classList.add("selected");
}