gtm4wp
gtm4wp copied to clipboard
fix "event.target.closest is not a function"
I have gtm4wp installed on my site, and I get a lot of event.target.closest is not a function
errors.
in "Additional Data" it says:
[
{
currentTarget: [object HTMLDocument],
isTrusted: False,
target: [object HTMLDocument],
type: focusin
}
]
and indeed - HTMLDocument
doesn't have a closest
function.
(try opening devtools and type document.closest
).
Surprisingly this happens in Chrome. I don't know when and why this happens, but when it does - the function fails and throws an error, so I'd rather it failing silently.
Screenshots from my Sentry issue:


bump
Thanks for adding this fix!