The property dataset
does not exist on type Element
, but does exist on HTMLElement
. You need to make sure it’s of this type before proceeding. It also works to adjust your for loop a bit:
for (const timelineEl of timelineEls) {
if (timelineEl instanceof HTMLElement) {
const progress = self.getProgress(timelineEl);
const timelineKey = timelineEl.dataset.scrollTimeline;
// ...
}
}