matthewhudson / current-device

📱 The easiest way to write conditional CSS and/or JavaScript based on device operating system (iOS, Android, Blackberry, Windows, Firefox OS, MeeGo), orientation (Portrait vs. Landscape), and type (Tablet vs. Mobile).
https://matthewhudson.github.io/current-device/
MIT License
3.95k stars 586 forks source link

Uncaught TypeError: changeOrientationList[index] is not a function #233

Open hymair opened 4 years ago

hymair commented 4 years ago

This error is logged on resize.

image image

matthewhudson commented 4 years ago

Thanks for reporting @hymair.

I can't replicate it on my end. Can you share User Agent / more details where you discovered this?

hymair commented 4 years ago

Happens on latest Chrome. Here's some debugging:

image image

So looks like it's trying to execute landscape('landscape') as a function, but there's no such function. Let me know if you need any more specific info.

robertogrip commented 4 years ago

Would it be possible to validate if it is a function before?

typeof changeOrientationList[index] === 'function' && changeOrientationList[index](newOrientation);