esshorten
esshorten copied to clipboard
Workaround IE8 catch scope bug
In my setup mangle
at somepoint generated similar code:
var a = function () {...};
try {
...
} catch (a) {
...
}
return a();
It works on most browsers, but it fails in IE8, where a
is not local to catch scope, and overrides outer a
.
It'll be great to have either hardcoded workaround for that, or at least an option that will allow us to produce IE8 valid code.
Same applies to handling of function names, they're renamed not in context of surrounding scope, which of course is valid in ECMAScript, but error-prone for IE8 environment, as this name leaks to upper scope and we may have collisions, e.g.:
(function (foo) {
var x = foo();
return {
elo: function elo() { .. }
};
}());
Gets renamed to:
(function (a) {
var b = a();
return {
elo: function a() { .. }
};
}());
and in IE8 at var b = a()
it's function that's assigned to elo
property that's invoked.