Bug 1545004 - Do not fire "change" event on initialisation of timepicker; r=Fallen
authorGeoff Lankow <geoff@darktrojan.net>
Thu, 18 Apr 2019 12:37:32 +1200
changeset 26378 b5090b737682c766f6e8b743aca29a791bfbce95
parent 26377 72eadf95a12007ee4a2c5d02951ffd7851612628
child 26379 564deb03842feb687a6234d09ad032e73f207054
push id15810
push usergeoff@darktrojan.net
push dateThu, 18 Apr 2019 00:38:25 +0000
treeherdercomm-central@1e9b60bd5e34 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersFallen
bugs1545004
Bug 1545004 - Do not fire "change" event on initialisation of timepicker; r=Fallen
calendar/resources/content/datetimepickers/datetimepickers.js
--- a/calendar/resources/content/datetimepickers/datetimepickers.js
+++ b/calendar/resources/content/datetimepickers/datetimepickers.js
@@ -1012,20 +1012,24 @@ var { Services } = ChromeUtils.import("r
                 val = parseTime(val);
             } else if (Array.isArray(val)) {
                 let [hours, minutes] = val;
                 val = new Date();
                 val.setHours(hours);
                 val.setMinutes(minutes);
             }
             if (val.getHours() != this._hours || val.getMinutes() != this._minutes) {
+                let settingInitalValue = this._hours === undefined;
+
                 this._inputBoxValue = this._gridValue = val;
                 [this._hours, this._minutes] = this._gridValue;
 
-                this.dispatchEvent(new CustomEvent("change", { bubbles: true }));
+                if (!settingInitalValue) {
+                    this.dispatchEvent(new CustomEvent("change", { bubbles: true }));
+                }
             }
         }
 
         get value() {
             return [this._hours, this._minutes];
         }
 
         set _inputBoxValue(val) {