Fix 'onClick' callback on empty day

This commit is contained in:
KaKi87 2022-09-06 21:30:40 +02:00
parent c01f961769
commit 133f74f556
1 changed files with 2 additions and 1 deletions

View File

@ -144,10 +144,11 @@ export const create = ({
dayElement.setAttribute('data-gcg-month', date.getMonth().toString());
dayElement.addEventListener('click', () => {
if(typeof onClick === 'function'){
const timestampsString = dayElement.getAttribute('data-gcg-timestamps');
onClick({
day: parseInt(dayElement.getAttribute('data-gcg-day')),
month: parseInt(dayElement.getAttribute('data-gcg-month')),
timestamps: dayElement.getAttribute('data-gcg-timestamps').split(',').map(_ => parseInt(_))
timestamps: timestampsString ? timestampsString.split(',').map(_ => parseInt(_)) : []
});
}
});