From 59ca0731b8873a6e56b0851c0d46a37cecf17889 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 27 Apr 2023 03:37:31 -0400 Subject: [PATCH] Fix note editor not being properly unregistered from notifier --- chrome/content/zotero/elements/noteEditor.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/elements/noteEditor.js b/chrome/content/zotero/elements/noteEditor.js index 770290b5c0..5004e4f9b4 100644 --- a/chrome/content/zotero/elements/noteEditor.js +++ b/chrome/content/zotero/elements/noteEditor.js @@ -57,7 +57,7 @@ connectedCallback() { this._destroyed = false; - window.addEventListener("unload", this.destroy); + window.addEventListener("unload", () => this.destroy(), { once: true }); MozXULElement.insertFTLIfNeeded('toolkit/global/textActions.ftl'); document.l10n.connectRoot(this); @@ -95,7 +95,6 @@ if (this._destroyed) { return; } - window.removeEventListener("unload", this.destroy); this._destroyed = true; Zotero.Notifier.unregisterObserver(this._notifierID); @@ -364,7 +363,7 @@ connectedCallback() { this._destroyed = false; - window.addEventListener("unload", this.destroy); + window.addEventListener("unload", () => this.destroy(), { once: true }); this.append(document.importNode(this.content, true)); @@ -377,7 +376,6 @@ if (this._destroyed) { return; } - window.removeEventListener("unload", this.destroy); this._destroyed = true; }