Bug 1558599 - Don't manually tear down calendar appmenu buttons. r=mkmelin
authorPaul Morris <paul@paulwmorris.com>
Mon, 01 Jul 2019 17:27:12 +0200
changeset 36007 fe454c1cff8402bde8a5b625a977aeef95f54217
parent 36006 a9eca82028203e39962bebea90631ab0470cd3d0
child 36008 66aa32e146d4feb2164363028380ea2a11935daf
push id392
push userclokep@gmail.com
push dateMon, 02 Sep 2019 20:17:19 +0000
reviewersmkmelin
bugs1558599
Bug 1558599 - Don't manually tear down calendar appmenu buttons. r=mkmelin The event listeners will be removed automatically.
calendar/base/content/calendar-chrome-startup.js
--- a/calendar/base/content/calendar-chrome-startup.js
+++ b/calendar/base/content/calendar-chrome-startup.js
@@ -87,19 +87,16 @@ function commonFinishCalendar() {
     unloadCalendarManager();
 
     // clean up the unifinder
     finishCalendarToDoUnifinder();
 
     // Remove the command controller
     removeCalendarCommandController();
 
-    // Tear down calendar appmenu buttons.
-    tearDownCalendarAppMenuButtons();
-
     document.getElementById("calsidebar_splitter").removeEventListener("command", onCalendarViewResize);
     window.removeEventListener("resize", onCalendarViewResize, true);
 
     // Clean up window pref observers
     calendarWindowPrefs.cleanup();
 }
 
 /**
@@ -163,42 +160,31 @@ var calendarWindowPrefs = {
                 setElementValue(win.document.documentElement, attributeValue, "systemcolors");
             });
         }
     }
 };
 
 /**
  * Set up calendar appmenu buttons by adding event listeners to the buttons.
- * Also used to tear down the appmenu buttons by removing the event listeners.
- *
- * @param {boolean} [remove]  Whether to remove event listeners instead of adding them.
  */
-function setUpCalendarAppMenuButtons(remove) {
-    const addOrRemoveListener = remove ? "removeEventListener" : "addEventListener";
+function setUpCalendarAppMenuButtons() {
     [
         "calendar-appmenu-button",
         "task-appmenu-button",
         "calendar-item-appmenu-button"
     ]
     .forEach(id => {
         const button = document.getElementById(id);
-        button[addOrRemoveListener]("mousedown", PanelUI);
-        button[addOrRemoveListener]("keypress", PanelUI);
+        button.addEventListener("mousedown", PanelUI);
+        button.addEventListener("keypress", PanelUI);
     });
 }
 
 /**
- * Tear down calendar appmenu buttons by removing event listeners from them.
- */
-function tearDownCalendarAppMenuButtons() {
-    setUpCalendarAppMenuButtons(true);
-}
-
-/**
  * Event listener used to refresh the "Events and Tasks" menu/view in the appmenu.
  */
 function refreshEventsAndTasksMenu(event) {
     changeMenuForTask(event);
     setupDeleteMenuitem("appmenu_ltnDeleteSelectedCalendar");
 }
 
 /**