Bug 1568723 - follow-up: Wait for hbox binding to load before calling method on it. r+a=pmorris
authorGeoff Lankow <geoff@darktrojan.net>
Tue, 01 Oct 2019 11:50:34 +1300
changeset 35904 486b11051c9a12a7faae5e39df8722b5bb213176
parent 35903 2f458a041881233bd7c5f128855e2b2de500ffb6
child 35905 d58f8461b2ac605f4ea8810197f3c621ab663ddd
push id39
push usermozilla@jorgk.com
push dateSat, 05 Oct 2019 14:18:49 +0000
treeherdercomm-esr68@9ba6a8a5bcb8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1568723
Bug 1568723 - follow-up: Wait for hbox binding to load before calling method on it. r+a=pmorris
calendar/base/content/today-pane.js
--- a/calendar/base/content/today-pane.js
+++ b/calendar/base/content/today-pane.js
@@ -73,33 +73,38 @@ var TodayPane = {
     }
   },
 
   /**
    * Sets up the label for the switcher that allows switching between today pane
    * views. (event+task, task only, event only)
    */
   updateDisplay: function() {
+    let agendaPanel = document.getElementById("agenda-panel");
+    if (!("isVisible" in agendaPanel)) {
+      agendaPanel.addEventListener("bindingattached", () => this.updateDisplay(), { once: true });
+      return;
+    }
     let currentMode = document.getElementById("modeBroadcaster").getAttribute("mode");
-    let agendaIsVisible = document.getElementById("agenda-panel").isVisible(currentMode);
+    let agendaIsVisible = agendaPanel.isVisible(currentMode);
     let todoIsVisible = document.getElementById("todo-tab-panel").isVisible(currentMode);
     let index = 2;
     if (agendaIsVisible && todoIsVisible) {
       index = 0;
     } else if (!agendaIsVisible && todoIsVisible) {
       index = 1;
     } else if (agendaIsVisible && !todoIsVisible) {
       index = 2;
     } else {
       // agendaIsVisible == false && todoIsVisible == false:
       // In this case something must have gone wrong
       // - probably in the previous session - and no pane is displayed.
       // We set a default by only displaying agenda-pane.
       agendaIsVisible = true;
-      document.getElementById("agenda-panel").setVisible(agendaIsVisible);
+      agendaPanel.setVisible(agendaIsVisible);
       index = 2;
     }
     let todayHeader = document.getElementById("today-pane-header");
     todayHeader.setAttribute("index", index);
     todayHeader.setAttribute("value", this.paneViews[index]);
     let todayPaneSplitter = document.getElementById("today-pane-splitter");
     setBooleanAttribute(todayPaneSplitter, "hidden", index != 0);
     let todayIsVisible = document.getElementById("today-pane-panel").isVisible();