2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-30 15:24:11 +03:00

added proper detection of react-native in isStandardBrowserEnv function

This commit is contained in:
Viktor
2017-02-25 12:14:43 +01:00
parent 68ec2abc4a
commit 603bd2f66c
+6 -3
View File
@@ -169,19 +169,22 @@ function trim(str) {
*
* This allows axios to run in a web worker, and react-native.
* Both environments support XMLHttpRequest, but not fully standard globals.
* As of react-native 0.13, it can be identified from navigator.product.
*
* web workers:
* typeof window -> undefined
* typeof document -> undefined
*
* react-native:
* typeof document.createElement -> undefined
* navigator.product -> 'ReactNative'
*/
function isStandardBrowserEnv() {
if (typeof navigator.product !== 'undefined' && navigator.product === 'ReactNative') {
return false;
}
return (
typeof window !== 'undefined' &&
typeof document !== 'undefined' &&
typeof document.createElement === 'function'
typeof document !== 'undefined'
);
}