gtm4wp icon indicating copy to clipboard operation
gtm4wp copied to clipboard

fix "event.target.closest is not a function"

Open pinkasey opened this issue 2 years ago • 1 comments

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: image

image image

pinkasey avatar Sep 23 '22 08:09 pinkasey

bump

pinkasey avatar Oct 14 '22 11:10 pinkasey

Thanks for adding this fix!

duracelltomi avatar Oct 25 '22 14:10 duracelltomi