Bug 1724940 - Use onclick instead of event listeners in account setup tab to prevent lingering handlers. r=mkmelin a=wsmwk
authorAlessandro Castellani <alessandro@thunderbird.net>
Mon, 16 Aug 2021 13:06:32 +0300
changeset 43545 a996ef6a0cd45abb78de01d8ed8a203c8834d05a
parent 43544 a980445d5b2a2a77a50e9a6012d5fdb5300ab8b9
child 43546 8e8bdb1092372cef2683b5fc0d6f832baabd7f66
push id3253
push userthunderbird@calypsoblue.org
push dateMon, 23 Aug 2021 02:52:59 +0000
treeherdercomm-beta@80c9ace3664d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin, wsmwk
bugs1724940
Bug 1724940 - Use onclick instead of event listeners in account setup tab to prevent lingering handlers. r=mkmelin a=wsmwk Differential Revision: https://phabricator.services.mozilla.com/D122635
mail/components/accountcreation/content/accountSetup.js
--- a/mail/components/accountcreation/content/accountSetup.js
+++ b/mail/components/accountcreation/content/accountSetup.js
@@ -142,33 +142,25 @@ function confirmExchange(domain, okCallb
   let dialog = document.getElementById("exchangeDialog");
 
   document.l10n.setAttributes(
     document.getElementById("exchangeDialogQuestion"),
     "exchange-dialog-question",
     { domain }
   );
 
-  document.getElementById("exchangeDialogConfirmButton").addEventListener(
-    "click",
-    () => {
-      dialog.close();
-      okCallback();
-    },
-    { once: true }
-  );
-
-  document.getElementById("exchangeDialogCancelButton").addEventListener(
-    "click",
-    () => {
-      dialog.close();
-      cancelCallback(new UserCancelledException());
-    },
-    { once: true }
-  );
+  document.getElementById("exchangeDialogConfirmButton").onclick = () => {
+    dialog.close();
+    okCallback();
+  };
+
+  document.getElementById("exchangeDialogCancelButton").onclick = () => {
+    dialog.close();
+    cancelCallback(new UserCancelledException());
+  };
 
   // Show the dialog.
   dialog.showModal();
 
   let abortable = new Abortable();
   abortable.cancel = ex => {
     dialog.close();
     cancelCallback(ex);
@@ -2538,46 +2530,38 @@ var gAccountSetup = {
       alwaysCache || (canCache && calendar.getProperty("cache.enabled"));
 
     // Set up the "Refresh calendar" menulist.
     let calendarRefresh = document.getElementById("calendaRefresh");
     calendarRefresh.disabled = !calendar.canRefresh;
     calendarRefresh.value = calendar.getProperty("refreshInterval") || 30;
 
     // Set up the dialog's action buttons.
-    document.getElementById("calendarDialogConfirmButton").addEventListener(
-      "click",
-      () => {
-        // Update the attributes of the calendar in case the user changed some
-        // values.
-        calendar.name = nameInput.value;
-        calendar.setProperty("color", colorInput.value);
-        if (calendar.canRefresh) {
-          calendar.setProperty("refreshInterval", calendarRefresh.value);
-        }
-
-        calendar.readOnly = readOnlyCheckbox.checked;
-        calendar.setProperty("suppressAlarms", !remindersCheckbox.checked);
-        if (!alwaysCache) {
-          calendar.setProperty("cache.enabled", offlineCheckbox.checked);
-        }
-
-        this._setupCalendar(button, calendar);
-        dialog.close();
-      },
-      { once: true }
-    );
-
-    document.getElementById("calendarDialogCancelButton").addEventListener(
-      "click",
-      () => {
-        dialog.close();
-      },
-      { once: true }
-    );
+    document.getElementById("calendarDialogConfirmButton").onclick = () => {
+      // Update the attributes of the calendar in case the user changed some
+      // values.
+      calendar.name = nameInput.value;
+      calendar.setProperty("color", colorInput.value);
+      if (calendar.canRefresh) {
+        calendar.setProperty("refreshInterval", calendarRefresh.value);
+      }
+
+      calendar.readOnly = readOnlyCheckbox.checked;
+      calendar.setProperty("suppressAlarms", !remindersCheckbox.checked);
+      if (!alwaysCache) {
+        calendar.setProperty("cache.enabled", offlineCheckbox.checked);
+      }
+
+      this._setupCalendar(button, calendar);
+      dialog.close();
+    };
+
+    document.getElementById("calendarDialogCancelButton").onclick = () => {
+      dialog.close();
+    };
 
     dialog.showModal();
   },
 
   /**
    * Connect to the selected calendar.
    *
    * @param {HTMLElement} button - The clicked button in the list.