Bug 1540522 - make datepicker and timepicker work even if there's no menulist already set up. r=darktrojan
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Fri, 12 Apr 2019 13:58:16 +0300
changeset 26338 552dd1355efae3044c6008fcea598ff23f459f0b
parent 26337 38970ece368e7f1c76b511c18d92b0ffc62942f0
child 26339 d95e0ca4fedd04f85b5490be29ecaa25fd0eff1a
push id15793
push usermozilla@jorgk.com
push dateSun, 14 Apr 2019 21:52:15 +0000
treeherdercomm-central@4f2702e359aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdarktrojan
bugs1540522
Bug 1540522 - make datepicker and timepicker work even if there's no menulist already set up. r=darktrojan
calendar/resources/content/datetimepickers/datetimepickers.js
mail/base/content/mailWidgets.js
--- a/calendar/resources/content/datetimepickers/datetimepickers.js
+++ b/calendar/resources/content/datetimepickers/datetimepickers.js
@@ -1,17 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, you can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* globals MozElements, MozXULElement, cal */
 
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
-customElements.whenDefined("menulist-editable").then(() => {
+{
     class MozTimepickerMinute extends MozXULElement {
         static get observedAttributes() {
             return ["label", "selected"];
         }
 
         constructor() {
             super();
 
@@ -1106,17 +1106,17 @@ customElements.whenDefined("menulist-edi
     initDateFormat();
     initTimeFormat();
     customElements.define("timepicker-minute", MozTimepickerMinute);
     customElements.define("timepicker-hour", MozTimepickerHour);
     customElements.define("timepicker-grids", MozTimepickerGrids);
     customElements.define("datepicker", CalendarDatePicker);
     customElements.define("timepicker", CalendarTimePicker);
     customElements.define("datetimepicker", CalendarDateTimePicker);
-});
+}
 
 /**
  * Parameter aValue may be a date or a date time. Dates are
  * read according to locale/OS setting (d-m-y or m-d-y or ...).
  * (see initDateFormat). Uses parseTime() for times.
  */
 function parseDateTime(aValue) {
     this.mLastDateParseIncludedTime = false;
--- a/mail/base/content/mailWidgets.js
+++ b/mail/base/content/mailWidgets.js
@@ -565,16 +565,21 @@ class MozThreadPaneTreeColpicker extends
       destFolder.setStringProperty(propName, colStateString(destFolder));
       // null out to avoid memory bloat
       destFolder.msgDatabase = null;
     }
   }
 }
 customElements.define("thread-pane-treecolpicker", MozThreadPaneTreeColpicker, { extends: "treecolpicker" });
 
+// The menulist CE is defined lazily. Create one now to get menulist defined,
+// allowing us to inherit from it.
+if (!customElements.get("menulist")) {
+  delete document.createElement("menulist");
+}
 customElements.whenDefined("menulist").then(() => {
   /**
    * MozMenulistEditable is a menulist widget that can be made editable by setting editable="true".
    * With an additional type="description" the list also contains an additional label that can hold
    * for instance, a description of a menu item.
    * It is typically used e.g. for the "Custom From Address..." feature to let the user chose and
    * edit the address to send from.
    * @extends {MozMenuList}