@@ -192,7 +192,11 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
|
|||||||
// pass 3: fix up any scoping issue with IE8
|
// pass 3: fix up any scoping issue with IE8
|
||||||
if (options.ie8) self.walk(new TreeWalker(function(node) {
|
if (options.ie8) self.walk(new TreeWalker(function(node) {
|
||||||
if (node instanceof AST_SymbolCatch) {
|
if (node instanceof AST_SymbolCatch) {
|
||||||
redefine(node, node.thedef.defun);
|
var scope = node.thedef.defun;
|
||||||
|
if (scope.name instanceof AST_SymbolLambda && scope.name.name == node.name) {
|
||||||
|
scope = scope.parent_scope;
|
||||||
|
}
|
||||||
|
redefine(node, scope);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (node instanceof AST_SymbolLambda) {
|
if (node instanceof AST_SymbolLambda) {
|
||||||
|
|||||||
@@ -4388,7 +4388,7 @@ replace_all_var: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
replace_all_var_scope: {
|
replace_all_var_scope: {
|
||||||
rename = true;
|
rename = true
|
||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
|
|||||||
@@ -1150,7 +1150,7 @@ issue_2620_3: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
issue_2620_4: {
|
issue_2620_4: {
|
||||||
rename = true,
|
rename = true
|
||||||
options = {
|
options = {
|
||||||
dead_code: true,
|
dead_code: true,
|
||||||
evaluate: true,
|
evaluate: true,
|
||||||
|
|||||||
@@ -1081,3 +1081,111 @@ issue_3471_ie8: {
|
|||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_3473: {
|
||||||
|
rename = true
|
||||||
|
mangle = {
|
||||||
|
ie8: false,
|
||||||
|
toplevel: false,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var d = 42, a = 100, b = 10, c = 0;
|
||||||
|
(function b() {
|
||||||
|
try {
|
||||||
|
c++;
|
||||||
|
} catch (b) {}
|
||||||
|
})();
|
||||||
|
console.log(a, b, c);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var d = 42, a = 100, b = 10, c = 0;
|
||||||
|
(function a() {
|
||||||
|
try {
|
||||||
|
c++;
|
||||||
|
} catch (a) {}
|
||||||
|
})();
|
||||||
|
console.log(a, b, c);
|
||||||
|
}
|
||||||
|
expect_stdout: "100 10 1"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_3473_ie8: {
|
||||||
|
rename = true
|
||||||
|
mangle = {
|
||||||
|
ie8: true,
|
||||||
|
toplevel: false,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var d = 42, a = 100, b = 10, c = 0;
|
||||||
|
(function b() {
|
||||||
|
try {
|
||||||
|
c++;
|
||||||
|
} catch (b) {}
|
||||||
|
})();
|
||||||
|
console.log(a, b, c);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var d = 42, a = 100, b = 10, c = 0;
|
||||||
|
(function b() {
|
||||||
|
try {
|
||||||
|
c++;
|
||||||
|
} catch (b) {}
|
||||||
|
})();
|
||||||
|
console.log(a, b, c);
|
||||||
|
}
|
||||||
|
expect_stdout: "100 10 1"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_3473_toplevel: {
|
||||||
|
rename = true
|
||||||
|
mangle = {
|
||||||
|
ie8: false,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var d = 42, a = 100, b = 10, c = 0;
|
||||||
|
(function b() {
|
||||||
|
try {
|
||||||
|
c++;
|
||||||
|
} catch (b) {}
|
||||||
|
})();
|
||||||
|
console.log(a, b, c);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var c = 42, o = 100, n = 10, t = 0;
|
||||||
|
(function c() {
|
||||||
|
try {
|
||||||
|
t++;
|
||||||
|
} catch (c) {}
|
||||||
|
})();
|
||||||
|
console.log(o, n, t);
|
||||||
|
}
|
||||||
|
expect_stdout: "100 10 1"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_3473_ie8_toplevel: {
|
||||||
|
rename = true
|
||||||
|
mangle = {
|
||||||
|
ie8: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var d = 42, a = 100, b = 10, c = 0;
|
||||||
|
(function b() {
|
||||||
|
try {
|
||||||
|
c++;
|
||||||
|
} catch (b) {}
|
||||||
|
})();
|
||||||
|
console.log(a, b, c);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var c = 42, o = 100, n = 10, t = 0;
|
||||||
|
(function n() {
|
||||||
|
try {
|
||||||
|
t++;
|
||||||
|
} catch (n) {}
|
||||||
|
})();
|
||||||
|
console.log(o, n, t);
|
||||||
|
}
|
||||||
|
expect_stdout: "100 10 1"
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ exports["parse"] = parse;
|
|||||||
exports["push_uniq"] = push_uniq;
|
exports["push_uniq"] = push_uniq;
|
||||||
exports["reserve_quoted_keys"] = reserve_quoted_keys;
|
exports["reserve_quoted_keys"] = reserve_quoted_keys;
|
||||||
exports["string_template"] = string_template;
|
exports["string_template"] = string_template;
|
||||||
|
exports["to_ascii"] = to_ascii;
|
||||||
exports["tokenizer"] = tokenizer;
|
exports["tokenizer"] = tokenizer;
|
||||||
exports["TreeTransformer"] = TreeTransformer;
|
exports["TreeTransformer"] = TreeTransformer;
|
||||||
exports["TreeWalker"] = TreeWalker;
|
exports["TreeWalker"] = TreeWalker;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
var assert = require("assert");
|
var assert = require("assert");
|
||||||
var readFileSync = require("fs").readFileSync;
|
var readFileSync = require("fs").readFileSync;
|
||||||
var SourceMapConsumer = require("source-map").SourceMapConsumer;
|
var SourceMapConsumer = require("source-map").SourceMapConsumer;
|
||||||
var UglifyJS = require("../..");
|
var UglifyJS = require("../node");
|
||||||
|
|
||||||
function read(path) {
|
function read(path) {
|
||||||
return readFileSync(path, "utf8");
|
return readFileSync(path, "utf8");
|
||||||
@@ -244,7 +244,7 @@ describe("sourcemaps", function() {
|
|||||||
assert.strictEqual(map.sourcesContent.length, 1);
|
assert.strictEqual(map.sourcesContent.length, 1);
|
||||||
assert.strictEqual(map.sourcesContent[0], code);
|
assert.strictEqual(map.sourcesContent[0], code);
|
||||||
var encoded = result.code.slice(result.code.lastIndexOf(",") + 1);
|
var encoded = result.code.slice(result.code.lastIndexOf(",") + 1);
|
||||||
map = JSON.parse(new Buffer(encoded, "base64").toString());
|
map = JSON.parse(UglifyJS.to_ascii(encoded));
|
||||||
assert.strictEqual(map.sourcesContent.length, 1);
|
assert.strictEqual(map.sourcesContent.length, 1);
|
||||||
assert.strictEqual(map.sourcesContent[0], code);
|
assert.strictEqual(map.sourcesContent[0], code);
|
||||||
result = UglifyJS.minify(result.code, {
|
result = UglifyJS.minify(result.code, {
|
||||||
|
|||||||
Reference in New Issue
Block a user