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,
|
||||
"es6": true,
|
||||
},
|
||||
"globals": {
|
||||
"global": true
|
||||
},
|
||||
"rules": {
|
||||
"comma-dangle": 0,
|
||||
"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 {keys, objectTypes, propTypes} = constants;
|
||||
let XMLHttpRequest = global.originalXMLHttpRequest || global.XMLHttpRequest;
|
||||
let typeConverters = {};
|
||||
let XMLHttpRequest = window.XMLHttpRequest;
|
||||
let sessionId;
|
||||
|
||||
// Check if XMLHttpRequest has been overridden, and get the native one if that's the case.
|
||||
if (XMLHttpRequest.__proto__ != window.XMLHttpRequestEventTarget) {
|
||||
let override = XMLHttpRequest;
|
||||
delete window.XMLHttpRequest;
|
||||
XMLHttpRequest = window.XMLHttpRequest;
|
||||
window.XMLHttpRequest = override;
|
||||
if (XMLHttpRequest.__proto__ != global.XMLHttpRequestEventTarget) {
|
||||
let fakeXMLHttpRequest = XMLHttpRequest;
|
||||
delete global.XMLHttpRequest;
|
||||
XMLHttpRequest = global.XMLHttpRequest;
|
||||
global.XMLHttpRequest = fakeXMLHttpRequest;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
Loading…
Reference in New Issue