2019-09-27 10:44:11 +00:00
|
|
|
// Browser environment sniffing
|
2019-01-12 03:33:27 +00:00
|
|
|
export const inBrowser = typeof window !== 'undefined';
|
2019-09-27 10:44:11 +00:00
|
|
|
export const inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
|
|
|
|
export const weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
|
2019-01-12 03:33:27 +00:00
|
|
|
export const UA = inBrowser && window.navigator.userAgent.toLowerCase();
|
|
|
|
export const isIE = UA && /msie|trident/.test(UA);
|
|
|
|
export const isIE9 = UA && UA.indexOf('msie 9.0') > 0;
|
2019-09-27 10:44:11 +00:00
|
|
|
export const isEdge = UA && UA.indexOf('edge/') > 0;
|
2019-09-28 10:00:24 +00:00
|
|
|
export const isAndroid = (UA && UA.indexOf('android') > 0) || weexPlatform === 'android';
|
|
|
|
export const isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || weexPlatform === 'ios';
|
2019-09-27 10:44:11 +00:00
|
|
|
export const isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
|
|
|
|
export const isPhantomJS = UA && /phantomjs/.test(UA);
|
|
|
|
export const isFF = UA && UA.match(/firefox\/(\d+)/);
|