Update RPC JS to use originalXMLHttpRequest
React Native now leaves the original object accessible when it "polyfills" objects. So we check for that, but still have the previous logic in place in case they change their minds.
This commit is contained in:
parent
2f9c6a0727
commit
725e9855fe
|
@ -6,6 +6,9 @@
|
||||||
"browser": true,
|
"browser": true,
|
||||||
"es6": true,
|
"es6": true,
|
||||||
},
|
},
|
||||||
|
"globals": {
|
||||||
|
"global": true
|
||||||
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"comma-dangle": 0,
|
"comma-dangle": 0,
|
||||||
"no-unused-vars": 1,
|
"no-unused-vars": 1,
|
||||||
|
|
12
lib/rpc.js
12
lib/rpc.js
|
@ -5,16 +5,16 @@ let constants = require('./constants');
|
||||||
let DEVICE_HOST = 'localhost:8082';
|
let DEVICE_HOST = 'localhost:8082';
|
||||||
|
|
||||||
let {keys, objectTypes, propTypes} = constants;
|
let {keys, objectTypes, propTypes} = constants;
|
||||||
|
let XMLHttpRequest = global.originalXMLHttpRequest || global.XMLHttpRequest;
|
||||||
let typeConverters = {};
|
let typeConverters = {};
|
||||||
let XMLHttpRequest = window.XMLHttpRequest;
|
|
||||||
let sessionId;
|
let sessionId;
|
||||||
|
|
||||||
// Check if XMLHttpRequest has been overridden, and get the native one if that's the case.
|
// Check if XMLHttpRequest has been overridden, and get the native one if that's the case.
|
||||||
if (XMLHttpRequest.__proto__ != window.XMLHttpRequestEventTarget) {
|
if (XMLHttpRequest.__proto__ != global.XMLHttpRequestEventTarget) {
|
||||||
let override = XMLHttpRequest;
|
let fakeXMLHttpRequest = XMLHttpRequest;
|
||||||
delete window.XMLHttpRequest;
|
delete global.XMLHttpRequest;
|
||||||
XMLHttpRequest = window.XMLHttpRequest;
|
XMLHttpRequest = global.XMLHttpRequest;
|
||||||
window.XMLHttpRequest = override;
|
global.XMLHttpRequest = fakeXMLHttpRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
Loading…
Reference in New Issue