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:
Scott Kyle 2015-10-20 23:59:02 -07:00
parent 2f9c6a0727
commit 725e9855fe
2 changed files with 9 additions and 6 deletions

View File

@ -6,6 +6,9 @@
"browser": true,
"es6": true,
},
"globals": {
"global": true
},
"rules": {
"comma-dangle": 0,
"no-unused-vars": 1,

View File

@ -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 = {