Description
It looks like onOutsideRange()
is recomputed for EVERY SINGLE DATE every single time the datepicker is interacted with, be it clicking, or even hovering over dates.
My test function:
isOutsideRange(day) {
console.log(counter++); // counter is a global variable
return false;
}
The result:
When opening the datepicker for the first time (clicking an input), Chrome debugger logs up to 2519:
When the mouse enters or leaves any calendar date, Chrome debugger logs an additional 560 (18 months worth of days?) calls. Finally, subsequent closing / opening of the datepicker logs an additional 160 calls (560 * 3, significant?)
If the isOutsideRange()
function is anything more than trivial, this results in a very noticeable performance slowdown.
Ideally, the result of isOutsideRange()
should be cached for each day, or should only be calculated for localized days, e.g. for all the dates currently visible ± 7 days (to account for outside days).