Getting error a.target.closest is not a function on some Chrome contexts:—
// Add URL to queue on mouse hover, after timeout
const mouseOverListener = (event) => {
const elm = event.target.closest("a");
if (elm && elm.href && !alreadyPrefetched.has(elm.href)) {
hoverTimer = setTimeout(() => {
addUrlToQueue(elm.href, true);
}, window.FPConfig.hoverDelay);
}
};
// Prefetch on touchstart on mobile
const touchStartListener = (event) => {
const elm = event.target.closest("a");
if (elm && elm.href && !alreadyPrefetched.has(elm.href))
addUrlToQueue(elm.href, true);
};
// Clear timeout on mouse out if not already prefetched
const mouseOutListener = (event) => {
const elm = event.target.closest("a");
if (elm && elm.href && !alreadyPrefetched.has(elm.href)) {
clearTimeout(hoverTimer);
}
};
Claude says: "This can happen if the event target is a text node or a non-element node."
Element.closest() method is supported in Chrome 75 but I'm seeing the error in Chrome 75-128.
Getting error
a.target.closest is not a functionon some Chrome contexts:—Claude says: "This can happen if the event target is a text node or a non-element node."
Element.closest() method is supported in Chrome 75 but I'm seeing the error in Chrome 75-128.