summaryrefslogtreecommitdiffstats
path: root/toolkit
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-03-30 21:14:18 +0200
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-03-30 21:14:18 +0200
commit6a44ab26592fbe95b69e1bf4d3a3b0de03a99b26 (patch)
tree5b24c0d79e0dc70e45dda1269d330f95c685c918 /toolkit
parent5e69b904229a13b423b6a2a1f3be4c50ffd2c505 (diff)
downloadUXP-6a44ab26592fbe95b69e1bf4d3a3b0de03a99b26.tar
UXP-6a44ab26592fbe95b69e1bf4d3a3b0de03a99b26.tar.gz
UXP-6a44ab26592fbe95b69e1bf4d3a3b0de03a99b26.tar.lz
UXP-6a44ab26592fbe95b69e1bf4d3a3b0de03a99b26.tar.xz
UXP-6a44ab26592fbe95b69e1bf4d3a3b0de03a99b26.zip
Bug 1364026 - (Part 2) Check if min and max attributes on input type date are valid date strings
Diffstat (limited to 'toolkit')
-rw-r--r--toolkit/content/browser-content.js4
-rw-r--r--toolkit/content/widgets/datekeeper.js15
-rw-r--r--toolkit/content/widgets/datepicker.js4
3 files changed, 13 insertions, 10 deletions
diff --git a/toolkit/content/browser-content.js b/toolkit/content/browser-content.js
index b955bd29d..145de9608 100644
--- a/toolkit/content/browser-content.js
+++ b/toolkit/content/browser-content.js
@@ -1728,8 +1728,8 @@ let DateTimePickerListener = {
// element's value.
value: Object.keys(value).length > 0 ? value
: this._inputElement.value,
- min: this._inputElement.min,
- max: this._inputElement.max,
+ min: this._inputElement.getMinimum(),
+ max: this._inputElement.getMaximum(),
step: this._inputElement.getStep(),
stepBase: this._inputElement.getStepBase(),
},
diff --git a/toolkit/content/widgets/datekeeper.js b/toolkit/content/widgets/datekeeper.js
index 9517e2154..4959b9609 100644
--- a/toolkit/content/widgets/datekeeper.js
+++ b/toolkit/content/widgets/datekeeper.js
@@ -16,9 +16,11 @@ function DateKeeper(props) {
MONTHS_IN_A_YEAR = 12,
YEAR_VIEW_SIZE = 200,
YEAR_BUFFER_SIZE = 10,
- // The min and max values are derived from the ECMAScript spec:
+ // The min value is 0001-01-01 based on HTML spec:
+ // https://html.spec.whatwg.org/#valid-date-string
+ MIN_DATE = -62135596800000,
+ // The max value is derived from the ECMAScript spec:
// http://ecma-international.org/ecma-262/5.1/#sec-15.9.1.1
- MIN_DATE = -8640000000000000,
MAX_DATE = 8640000000000000;
DateKeeper.prototype = {
@@ -43,8 +45,8 @@ function DateKeeper(props) {
* @param {Number} year
* @param {Number} month
* @param {Number} day
- * @param {String} min
- * @param {String} max
+ * @param {Number} min
+ * @param {Number} max
* @param {Number} step
* @param {Number} stepBase
* @param {Number} firstDayOfWeek
@@ -57,8 +59,9 @@ function DateKeeper(props) {
this.state = {
step, firstDayOfWeek, weekends, calViewSize,
- min: new Date(min != undefined ? min : MIN_DATE),
- max: new Date(max != undefined ? max : MAX_DATE),
+ // min & max are NaN if empty or invalid
+ min: new Date(Number.isNaN(min) ? MIN_DATE : min),
+ max: new Date(Number.isNaN(max) ? MAX_DATE : max),
stepBase: new Date(stepBase),
today: this._newUTCDate(today.getFullYear(), today.getMonth(), today.getDate()),
weekHeaders: this._getWeekHeaders(firstDayOfWeek, weekends),
diff --git a/toolkit/content/widgets/datepicker.js b/toolkit/content/widgets/datepicker.js
index 25b15dae6..0c288d917 100644
--- a/toolkit/content/widgets/datepicker.js
+++ b/toolkit/content/widgets/datepicker.js
@@ -20,8 +20,8 @@ function DatePicker(context) {
* {Number} year [optional]
* {Number} month [optional]
* {Number} date [optional]
- * {String} min
- * {String} max
+ * {Number} min
+ * {Number} max
* {Number} step
* {Number} stepBase
* {Number} firstDayOfWeek