Skip to content
This repository was archived by the owner on Jul 13, 2020. It is now read-only.

Commit 86ee1d9

Browse files
committed
ie8/9 cors fix
1 parent e17598e commit 86ee1d9

7 files changed

+30
-12
lines changed

dist/es6-module-loader-sans-promises.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/es6-module-loader-sans-promises.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/es6-module-loader-sans-promises.src.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,7 @@ function logloads(loads) {
12281228
fetchTextFromURL = function(url, fulfill, reject) {
12291229
var xhr = new XMLHttpRequest();
12301230
var sameDomain = true;
1231+
var doTimeout = false;
12311232
if (!('withCredentials' in xhr)) {
12321233
// check if same domain
12331234
var domainCheck = /^(\w+:)?\/\/([^\/]+)/.exec(url);
@@ -1242,10 +1243,9 @@ function logloads(loads) {
12421243
xhr.onload = load;
12431244
xhr.onerror = error;
12441245
xhr.ontimeout = error;
1245-
// IE8/IE9 bug may hang requests unless all properties are defined.
1246-
// See: http://stackoverflow.com/a/9928073/3949247
12471246
xhr.onprogress = function() {};
12481247
xhr.timeout = 0;
1248+
doTimeout = true;
12491249
}
12501250
function load() {
12511251
fulfill(xhr.responseText);
@@ -1264,6 +1264,12 @@ function logloads(loads) {
12641264
}
12651265
};
12661266
xhr.open("GET", url, true);
1267+
1268+
if (doTimeout)
1269+
setTimeout(function() {
1270+
xhr.send();
1271+
}, 0);
1272+
12671273
xhr.send(null);
12681274
}
12691275
}

dist/es6-module-loader.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/es6-module-loader.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/es6-module-loader.src.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2416,6 +2416,7 @@ function logloads(loads) {
24162416
fetchTextFromURL = function(url, fulfill, reject) {
24172417
var xhr = new XMLHttpRequest();
24182418
var sameDomain = true;
2419+
var doTimeout = false;
24192420
if (!('withCredentials' in xhr)) {
24202421
// check if same domain
24212422
var domainCheck = /^(\w+:)?\/\/([^\/]+)/.exec(url);
@@ -2430,10 +2431,9 @@ function logloads(loads) {
24302431
xhr.onload = load;
24312432
xhr.onerror = error;
24322433
xhr.ontimeout = error;
2433-
// IE8/IE9 bug may hang requests unless all properties are defined.
2434-
// See: http://stackoverflow.com/a/9928073/3949247
24352434
xhr.onprogress = function() {};
24362435
xhr.timeout = 0;
2436+
doTimeout = true;
24372437
}
24382438
function load() {
24392439
fulfill(xhr.responseText);
@@ -2452,6 +2452,12 @@ function logloads(loads) {
24522452
}
24532453
};
24542454
xhr.open("GET", url, true);
2455+
2456+
if (doTimeout)
2457+
setTimeout(function() {
2458+
xhr.send();
2459+
}, 0);
2460+
24552461
xhr.send(null);
24562462
}
24572463
}

src/system.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
fetchTextFromURL = function(url, fulfill, reject) {
6565
var xhr = new XMLHttpRequest();
6666
var sameDomain = true;
67+
var doTimeout = false;
6768
if (!('withCredentials' in xhr)) {
6869
// check if same domain
6970
var domainCheck = /^(\w+:)?\/\/([^\/]+)/.exec(url);
@@ -78,10 +79,9 @@
7879
xhr.onload = load;
7980
xhr.onerror = error;
8081
xhr.ontimeout = error;
81-
// IE8/IE9 bug may hang requests unless all properties are defined.
82-
// See: http://stackoverflow.com/a/9928073/3949247
8382
xhr.onprogress = function() {};
8483
xhr.timeout = 0;
84+
doTimeout = true;
8585
}
8686
function load() {
8787
fulfill(xhr.responseText);
@@ -100,6 +100,12 @@
100100
}
101101
};
102102
xhr.open("GET", url, true);
103+
104+
if (doTimeout)
105+
setTimeout(function() {
106+
xhr.send();
107+
}, 0);
108+
103109
xhr.send(null);
104110
}
105111
}

0 commit comments

Comments
 (0)