-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update browser support check #2560
Conversation
even though if/else tends to be faster, the resulting js of this switch is more concise
, /BlackBerry/i.test(window.navigator.userAgent) | ||
, /BB10/i.test(window.navigator.userAgent) | ||
false | ||
when /Android/i.test(window.navigator.userAgent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nb] Why not /Android/i.test(window.navigator.userAgent) and /Mobile/i.test(window.navigator.userAgent);
here?
I find it slightly harder to skim read what's going on like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(some sort of) consistency; this way all tests are on their own line
Should we care about the resulting JS? |
I'm actually not sure if |
I've reverted to an |
Maybe we should put the |
@koenpunt moving it to the top is a good idea. It may even help UglifyJS optimizations, as it will see a |
/Windows Phone/i.test(window.navigator.userAgent) or | ||
/BlackBerry/i.test(window.navigator.userAgent) or | ||
/BB10/i.test(window.navigator.userAgent) or | ||
/Android.*Mobile/i.test(window.navigator.userAgent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@koenpunt There's a subtle change here — this will no longer match the opposite order, e.g. Mobile blah blah Android
, which the original did.
Not sure if anything has a user agent like that, but just pointing out that this is not 100% equivalent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, but Mobile
always appears after Android
according to https://developer.chrome.com/multidevice/user-agent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I tend to prefer readability over micro optimizations that save us a few characters. In this case, however, it seems we get both! I find the changes slightly more readable so I'm 👍 Gonna merge it in. Thanks @koenpunt! |
Old
New