ten1seven / what-input

A global utility for tracking the current input method (mouse/pointer, keyboard or touch).
https://ten1seven.github.io/what-input
MIT License
1.35k stars 89 forks source link

Cannot read property 'toLowerCase' of undefined #73

Closed thebuilder closed 6 years ago

thebuilder commented 6 years ago

I'm seeing this happen across all browsers (Chrome, Safari 11, IE): https://sentry.io/share/issue/2a3086e854984946a535c53daf14aed7/

currentElement = event.target.nodeName.toLowerCase();
docElem.setAttribute('data-whatelement', currentElement);

Seems to be caused by the user clicking on a <svg>, and the browser returning nodeName as undefined. Like, if the user clicks on a "Share" button on our site.

Is setting currentElement critical or a nice feature? regardless, it should check if nodeName exists before calling toLowerCase(). I'll make pull request.