Bug 1328219 - (Part 1) Add a PickerReady event for testing and check if picker exists before updating. r=mconley draft
authorScott Wu <scottcwwu@gmail.com>
Wed, 02 Aug 2017 17:05:38 +0800
changeset 643034 60597a0980c0a1b4c44af83c6c28a59d760307ea
parent 619581 52285ea5e54c73d3ed824544cef2ee3f195f05e6
child 643035 150b5fb09736c5e5e0f0bede463a1a4e0358074e
child 643090 fadd2257a7e3b7c4405d671e83f32a0758342a03
child 643964 b203d0a530a1325cb3bad16c81e3c71d0f7055bb
child 644562 2e77ecbdcccc44a8bf8dc4e0c2fcf8d7c6425109
push id72960
push userbmo:scwwu@mozilla.com
push dateWed, 09 Aug 2017 06:44:48 +0000
reviewersmconley
bugs1328219
milestone57.0a1
Bug 1328219 - (Part 1) Add a PickerReady event for testing and check if picker exists before updating. r=mconley MozReview-Commit-ID: 2GGdWskTZwJ
toolkit/content/widgets/datepicker.js
toolkit/modules/DateTimePickerHelper.jsm
--- a/toolkit/content/widgets/datepicker.js
+++ b/toolkit/content/widgets/datepicker.js
@@ -35,16 +35,17 @@ function DatePicker(context) {
      *           {String} locale [optional]: User preferred locale
      *         }
      */
     init(props = {}) {
       this.props = props;
       this._setDefaultState();
       this._createComponents();
       this._update();
+      document.dispatchEvent(new CustomEvent("PickerReady"));
     },
 
     /*
      * Set initial date picker states.
      */
     _setDefaultState() {
       const { year, month, day, min, max, step, stepBase, firstDayOfWeek, weekends,
               monthStrings, weekdayStrings, locale, dir } = this.props;
--- a/toolkit/modules/DateTimePickerHelper.jsm
+++ b/toolkit/modules/DateTimePickerHelper.jsm
@@ -61,16 +61,19 @@ this.DateTimePickerHelper = {
       case "FormDateTime:ClosePicker": {
         if (!this.picker) {
           return;
         }
         this.picker.closePicker();
         break;
       }
       case "FormDateTime:UpdatePicker": {
+        if (!this.picker) {
+          return;
+        }
         this.picker.setPopupValue(aMessage.data);
         break;
       }
       default:
         break;
     }
   },