summaryrefslogtreecommitdiffstats
path: root/toolkit/content/widgets
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/content/widgets
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/content/widgets')
-rw-r--r--toolkit/content/widgets/datekeeper.js15
-rw-r--r--toolkit/content/widgets/datepicker.js4
2 files changed, 11 insertions, 8 deletions
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