Merge pull request #1572 from ericvergnaud/fix-require-issue-in-IE-web-worker

fix an issue where loading antlr from an IE web worker would fail
This commit is contained in:
Terence Parr 2017-01-03 17:05:23 -08:00 committed by GitHub
commit 0dfcc1822f
1 changed files with 10 additions and 7 deletions

View File

@ -62,13 +62,16 @@
// anchor element as parser in that case. Thes breaks web worker support,
// but we don't care since these browsers also don't support web workers.
try {
var parser = new URL(location.href);
}
catch (e) {
console.warn("Honey: falling back to DOM workaround for URL parser ("+e+")");
parser = document.createElement('A');
}
var parser = (function() {
try {
return new URL(location.href);
} catch(e) {
var p = Object.create(location);
// need to set writable, because WorkerLocation is read-only
Object.defineProperty(p, "href", {writable:true});
return p;
}
})();
// INFO Module cache
// Contains getter functions for the exports objects of all the loaded