fix an issue where loading antlr from an IE web worker would fail

This commit is contained in:
Eric Vergnaud 2017-01-04 01:56:02 +08:00
parent aa909ddcb1
commit d5dcfc42c4
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