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

Degrade gracefully in unsupported browsers #13

Closed slavanga closed 8 years ago

slavanga commented 8 years ago

I would like to see a simple “cut the mustard” style check to prevent errors in old browsers. There is a polyfill for IE 8 but I think the utility should degrade gracefully even without the polyfill.

A simple check like this would be enough to prevent errors:

if(!'addEventListener' in window && !!Array.prototype.indexOf) return;
ten1seven commented 8 years ago

Excellent suggestion! I might look at doing a more specific "mustard cutting" specific to the features I'm using and see about testing for the polyfills as well so there doesn't need to be two versions (polyfill and non-polyfill supported).

ten1seven commented 8 years ago

Thanks again for the suggestion! Let me know if you have any issues with that working in the wild.

slavanga commented 8 years ago

Awesome! Thank you for the quick implementation. Looks good so far...