Skip to content

Commit

Permalink
Remove ie8/9 special CORS treatment and btoa polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
RikkiGibson authored and emilyemorehouse committed Jun 1, 2019
1 parent 91f3bb2 commit efc0b58
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions lib/adapters/xhr.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var buildURL = require('./../helpers/buildURL');
var parseHeaders = require('./../helpers/parseHeaders');
var isURLSameOrigin = require('./../helpers/isURLSameOrigin');
var createError = require('../core/createError');
var btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || require('./../helpers/btoa');

module.exports = function xhrAdapter(config) {
return new Promise(function dispatchXhrRequest(resolve, reject) {
Expand All @@ -18,22 +17,6 @@ module.exports = function xhrAdapter(config) {
}

var request = new XMLHttpRequest();
var loadEvent = 'onreadystatechange';
var xDomain = false;

// For IE 8/9 CORS support
// Only supports POST and GET calls and doesn't returns the response headers.
// DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest.
if (process.env.NODE_ENV !== 'test' &&
typeof window !== 'undefined' &&
window.XDomainRequest && !('withCredentials' in request) &&
!isURLSameOrigin(config.url)) {
request = new window.XDomainRequest();
loadEvent = 'onload';
xDomain = true;
request.onprogress = function handleProgress() {};
request.ontimeout = function handleTimeout() {};
}

// HTTP basic authentication
if (config.auth) {
Expand All @@ -48,8 +31,8 @@ module.exports = function xhrAdapter(config) {
request.timeout = config.timeout;

// Listen for ready state
request[loadEvent] = function handleLoad() {
if (!request || (request.readyState !== 4 && !xDomain)) {
request.onreadystatechange = function handleLoad() {
if (!request || request.readyState !== 4) {
return;
}

Expand Down

0 comments on commit efc0b58

Please sign in to comment.