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

Element.classList not available in ie9 #45

Closed hooleyhoop closed 7 years ago

hooleyhoop commented 7 years ago

could / should a check be added in with the “cut the mustard” tests for indexOf and EventListener? Alternatively classList could be avoided all together. Happy to help out if i can.

ten1seven commented 7 years ago

Hi @hooleyhoop, those tests are included before the script inits. There's also polyfills included if you need support for older IE's. Support for classList goes back to IE9. Are you needing IE8 support?

It's a good call to add classList as a check in the cut-the-mustard. I'm up for adding a polyfill but want to keep the core script lightweight. Thanks!

hooleyhoop commented 7 years ago

Sorry for the noise, a quick check of caniuse suggested ie9 didn't have support, but actually the errors i'm seeing are from old Safari (5) and Android Browser (2.3).

I think the cut-the-mustard check and polyfill can be completely avoided by using className instead of classList, so..

docElem.className += ' whatinput-types-' + currentInput;

instead of

docElem.classList.add('whatinput-types-' + currentInput);