mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Remove added eventListener on disconnect
It's good practise to remove added event listener to avoid memory leak
This commit is contained in:
@@ -7,6 +7,11 @@ export default class extends Controller {
|
||||
this.element.addEventListener("trix-initialize", this.#trixInitialize);
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
this.element.removeEventListener("trix-change", this.#trixChange);
|
||||
this.element.removeEventListener("trix-initialize", this.#trixInitialize);
|
||||
}
|
||||
|
||||
#trixChange = (event) => {
|
||||
// trigger a change event on the form that contains the Trix editor
|
||||
event.target.form.dispatchEvent(new Event("change", { bubbles: true }));
|
||||
|
||||
Reference in New Issue
Block a user