Skip to content

Commit

Permalink
fix(calendar): return null instead of undefined in sanitizer
Browse files Browse the repository at this point in the history
The date sanitizer returns undefined when the date argument is not a valid date object or
date string which doesn't allow to reset the date value especially for min and max date by
passing null value via `set minDate` and `set MaxDate`.

This PR makes the `sanitiseDate` method to return null if the value of date argument is not
valid date object or date string.

Close: #1776
  • Loading branch information
ko2in authored Nov 24, 2020
1 parent aa04e6d commit de2ba9f
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/definitions/modules/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1074,14 +1074,11 @@ $.fn.calendar = function(parameters) {
return null;
},
sanitiseDate: function (date) {
if (!date) {
return undefined;
}
if (!(date instanceof Date)) {
date = parser.date('' + date, settings);
}
if (!date || date === null || isNaN(date.getTime())) {
return undefined;
if (!date || isNaN(date.getTime())) {
return null;
}
return date;
},
Expand Down

0 comments on commit de2ba9f

Please sign in to comment.