minor clean-ups (#5701)
This commit is contained in:
@@ -3,7 +3,7 @@ Contributing
|
|||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
Every new feature and API change should be accompanied by a README additon.
|
Every new feature and API change should be accompanied by a README addition.
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
|
|||||||
@@ -646,7 +646,7 @@ to be `false` and all symbol names will be omitted.
|
|||||||
- `bare_returns` (default: `false`) — support top level `return` statements
|
- `bare_returns` (default: `false`) — support top level `return` statements
|
||||||
|
|
||||||
- `html5_comments` (default: `true`) — process HTML comment as workaround for
|
- `html5_comments` (default: `true`) — process HTML comment as workaround for
|
||||||
browsers which do not recognise `<script>` tags
|
browsers which do not recognize `<script>` tags
|
||||||
|
|
||||||
- `module` (default: `false`) — set to `true` if you wish to process input as
|
- `module` (default: `false`) — set to `true` if you wish to process input as
|
||||||
ES module, i.e. implicit `"use strict";` and support for top-level `await`.
|
ES module, i.e. implicit `"use strict";` and support for top-level `await`.
|
||||||
@@ -753,7 +753,7 @@ to be `false` and all symbol names will be omitted.
|
|||||||
ES module, i.e. implicit `"use strict";` alongside with `toplevel` enabled.
|
ES module, i.e. implicit `"use strict";` alongside with `toplevel` enabled.
|
||||||
|
|
||||||
- `negate_iife` (default: `true`) — negate "Immediately-Called Function Expressions"
|
- `negate_iife` (default: `true`) — negate "Immediately-Called Function Expressions"
|
||||||
where the return value is discarded, to avoid the parens that the
|
where the return value is discarded, to avoid the parentheses that the
|
||||||
code generator would insert.
|
code generator would insert.
|
||||||
|
|
||||||
- `objects` (default: `true`) — compact duplicate keys in object literals.
|
- `objects` (default: `true`) — compact duplicate keys in object literals.
|
||||||
@@ -851,7 +851,7 @@ to be `false` and all symbol names will be omitted.
|
|||||||
- `unused` (default: `true`) — drop unreferenced functions and variables (simple
|
- `unused` (default: `true`) — drop unreferenced functions and variables (simple
|
||||||
direct variable assignments do not count as references unless set to `"keep_assign"`)
|
direct variable assignments do not count as references unless set to `"keep_assign"`)
|
||||||
|
|
||||||
- `varify` (default: `true`) — convert block-scoped declaractions into `var`
|
- `varify` (default: `true`) — convert block-scoped declarations into `var`
|
||||||
whenever safe to do so
|
whenever safe to do so
|
||||||
|
|
||||||
- `yields` (default: `true`) — apply optimizations to `yield` expressions
|
- `yields` (default: `true`) — apply optimizations to `yield` expressions
|
||||||
|
|||||||
@@ -332,7 +332,7 @@ var AST_SimpleStatement = DEFNODE("SimpleStatement", "body", {
|
|||||||
var AST_BlockScope = DEFNODE("BlockScope", "_var_names enclosed functions make_def parent_scope variables", {
|
var AST_BlockScope = DEFNODE("BlockScope", "_var_names enclosed functions make_def parent_scope variables", {
|
||||||
$documentation: "Base class for all statements introducing a lexical scope",
|
$documentation: "Base class for all statements introducing a lexical scope",
|
||||||
$propdoc: {
|
$propdoc: {
|
||||||
enclosed: "[SymbolDef*/S] a list of all symbol definitions that are accessed from this scope or any subscopes",
|
enclosed: "[SymbolDef*/S] a list of all symbol definitions that are accessed from this scope or any inner scopes",
|
||||||
functions: "[Dictionary/S] like `variables`, but only lists function declarations",
|
functions: "[Dictionary/S] like `variables`, but only lists function declarations",
|
||||||
parent_scope: "[AST_Scope?/S] link to the parent scope",
|
parent_scope: "[AST_Scope?/S] link to the parent scope",
|
||||||
variables: "[Dictionary/S] a map of name ---> SymbolDef for all variables/functions defined in this scope",
|
variables: "[Dictionary/S] a map of name ---> SymbolDef for all variables/functions defined in this scope",
|
||||||
|
|||||||
@@ -368,7 +368,6 @@ Compressor.prototype.compress = function(node) {
|
|||||||
args: [],
|
args: [],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return self;
|
|
||||||
});
|
});
|
||||||
AST_Node.DEFMETHOD("wrap_expression", function() {
|
AST_Node.DEFMETHOD("wrap_expression", function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
@@ -5083,7 +5082,7 @@ Compressor.prototype.compress = function(node) {
|
|||||||
return static_fn && (static_fn[node.property] || expr.name == "Math" && node.property == "random");
|
return static_fn && (static_fn[node.property] || expr.name == "Math" && node.property == "random");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accomodate when compress option evaluate=false
|
// Accommodate when compress option evaluate=false
|
||||||
// as well as the common constant expressions !0 and -1
|
// as well as the common constant expressions !0 and -1
|
||||||
(function(def) {
|
(function(def) {
|
||||||
def(AST_Node, return_false);
|
def(AST_Node, return_false);
|
||||||
@@ -11882,7 +11881,7 @@ Compressor.prototype.compress = function(node) {
|
|||||||
if (nullish ? ll == null : !ll) {
|
if (nullish ? ll == null : !ll) {
|
||||||
AST_Node.warn("Condition left of {operator} always {value} [{start}]", {
|
AST_Node.warn("Condition left of {operator} always {value} [{start}]", {
|
||||||
operator: self.operator,
|
operator: self.operator,
|
||||||
value: nullish ? "nulish" : "false",
|
value: nullish ? "nullish" : "false",
|
||||||
start: self.start,
|
start: self.start,
|
||||||
});
|
});
|
||||||
return make_sequence(self, [ self.left, self.right ]).optimize(compressor);
|
return make_sequence(self, [ self.left, self.right ]).optimize(compressor);
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ function OutputStream(options) {
|
|||||||
wrap_iife : false,
|
wrap_iife : false,
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
// Convert comment option to RegExp if neccessary and set up comments filter
|
// Convert comment option to RegExp if necessary and set up comments filter
|
||||||
var comment_filter = return_false; // Default case, throw all comments away
|
var comment_filter = return_false; // Default case, throw all comments away
|
||||||
if (options.comments) {
|
if (options.comments) {
|
||||||
var comments = options.comments;
|
var comments = options.comments;
|
||||||
@@ -997,7 +997,7 @@ function OutputStream(options) {
|
|||||||
if (self.init instanceof AST_Definitions) {
|
if (self.init instanceof AST_Definitions) {
|
||||||
self.init.print(output);
|
self.init.print(output);
|
||||||
} else {
|
} else {
|
||||||
parenthesize_for_noin(self.init, output, true);
|
parenthesize_for_no_in(self.init, output, true);
|
||||||
}
|
}
|
||||||
output.print(";");
|
output.print(";");
|
||||||
output.space();
|
output.space();
|
||||||
@@ -1413,7 +1413,7 @@ function OutputStream(options) {
|
|||||||
print_braced(this, output);
|
print_braced(this, output);
|
||||||
});
|
});
|
||||||
|
|
||||||
function print_definitinos(type) {
|
function print_definitions(type) {
|
||||||
return function(output) {
|
return function(output) {
|
||||||
var self = this;
|
var self = this;
|
||||||
output.print(type);
|
output.print(type);
|
||||||
@@ -1426,15 +1426,15 @@ function OutputStream(options) {
|
|||||||
if (!(p instanceof AST_IterationStatement && p.init === self)) output.semicolon();
|
if (!(p instanceof AST_IterationStatement && p.init === self)) output.semicolon();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
DEFPRINT(AST_Const, print_definitinos("const"));
|
DEFPRINT(AST_Const, print_definitions("const"));
|
||||||
DEFPRINT(AST_Let, print_definitinos("let"));
|
DEFPRINT(AST_Let, print_definitions("let"));
|
||||||
DEFPRINT(AST_Var, print_definitinos("var"));
|
DEFPRINT(AST_Var, print_definitions("var"));
|
||||||
|
|
||||||
function parenthesize_for_noin(node, output, noin) {
|
function parenthesize_for_no_in(node, output, no_in) {
|
||||||
var parens = false;
|
var parens = false;
|
||||||
// need to take some precautions here:
|
// need to take some precautions here:
|
||||||
// https://github.com/mishoo/UglifyJS/issues/60
|
// https://github.com/mishoo/UglifyJS/issues/60
|
||||||
if (noin) node.walk(new TreeWalker(function(node) {
|
if (no_in) node.walk(new TreeWalker(function(node) {
|
||||||
if (parens) return true;
|
if (parens) return true;
|
||||||
if (node instanceof AST_Binary && node.operator == "in") return parens = true;
|
if (node instanceof AST_Binary && node.operator == "in") return parens = true;
|
||||||
if (node instanceof AST_Scope && !(is_arrow(node) && node.value)) return true;
|
if (node instanceof AST_Scope && !(is_arrow(node) && node.value)) return true;
|
||||||
@@ -1450,8 +1450,8 @@ function OutputStream(options) {
|
|||||||
output.print("=");
|
output.print("=");
|
||||||
output.space();
|
output.space();
|
||||||
var p = output.parent(1);
|
var p = output.parent(1);
|
||||||
var noin = p instanceof AST_For || p instanceof AST_ForEnumeration;
|
var no_in = p instanceof AST_For || p instanceof AST_ForEnumeration;
|
||||||
parenthesize_for_noin(self.value, output, noin);
|
parenthesize_for_no_in(self.value, output, no_in);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
48
lib/parse.js
48
lib/parse.js
@@ -782,7 +782,7 @@ function parse($TEXT, options) {
|
|||||||
else if (!optional && !can_insert_semicolon()) expect(";");
|
else if (!optional && !can_insert_semicolon()) expect(";");
|
||||||
}
|
}
|
||||||
|
|
||||||
function parenthesised() {
|
function parenthesized() {
|
||||||
expect("(");
|
expect("(");
|
||||||
var exp = expression();
|
var exp = expression();
|
||||||
expect(")");
|
expect(")");
|
||||||
@@ -920,18 +920,18 @@ function parse($TEXT, options) {
|
|||||||
next();
|
next();
|
||||||
var body = in_loop(statement);
|
var body = in_loop(statement);
|
||||||
expect_token("keyword", "while");
|
expect_token("keyword", "while");
|
||||||
var condition = parenthesised();
|
var condition = parenthesized();
|
||||||
semicolon(true);
|
semicolon(true);
|
||||||
return new AST_Do({
|
return new AST_Do({
|
||||||
body : body,
|
body : body,
|
||||||
condition : condition
|
condition : condition,
|
||||||
});
|
});
|
||||||
|
|
||||||
case "while":
|
case "while":
|
||||||
next();
|
next();
|
||||||
return new AST_While({
|
return new AST_While({
|
||||||
condition : parenthesised(),
|
condition : parenthesized(),
|
||||||
body : in_loop(statement)
|
body : in_loop(statement),
|
||||||
});
|
});
|
||||||
|
|
||||||
case "for":
|
case "for":
|
||||||
@@ -959,15 +959,13 @@ function parse($TEXT, options) {
|
|||||||
value = expression();
|
value = expression();
|
||||||
semicolon();
|
semicolon();
|
||||||
}
|
}
|
||||||
return new AST_Return({
|
return new AST_Return({ value: value });
|
||||||
value: value
|
|
||||||
});
|
|
||||||
|
|
||||||
case "switch":
|
case "switch":
|
||||||
next();
|
next();
|
||||||
return new AST_Switch({
|
return new AST_Switch({
|
||||||
expression : parenthesised(),
|
expression : parenthesized(),
|
||||||
body : in_loop(switch_body_)
|
body : in_loop(switch_body_),
|
||||||
});
|
});
|
||||||
|
|
||||||
case "throw":
|
case "throw":
|
||||||
@@ -976,9 +974,7 @@ function parse($TEXT, options) {
|
|||||||
croak("Illegal newline after 'throw'");
|
croak("Illegal newline after 'throw'");
|
||||||
var value = expression();
|
var value = expression();
|
||||||
semicolon();
|
semicolon();
|
||||||
return new AST_Throw({
|
return new AST_Throw({ value: value });
|
||||||
value: value
|
|
||||||
});
|
|
||||||
|
|
||||||
case "try":
|
case "try":
|
||||||
next();
|
next();
|
||||||
@@ -996,8 +992,8 @@ function parse($TEXT, options) {
|
|||||||
}
|
}
|
||||||
next();
|
next();
|
||||||
return new AST_With({
|
return new AST_With({
|
||||||
expression : parenthesised(),
|
expression : parenthesized(),
|
||||||
body : statement()
|
body : statement(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1421,15 +1417,15 @@ function parse($TEXT, options) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function if_() {
|
function if_() {
|
||||||
var cond = parenthesised(), body = statement(), belse = null;
|
var cond = parenthesized(), body = statement(), alt = null;
|
||||||
if (is("keyword", "else")) {
|
if (is("keyword", "else")) {
|
||||||
next();
|
next();
|
||||||
belse = statement();
|
alt = statement();
|
||||||
}
|
}
|
||||||
return new AST_If({
|
return new AST_If({
|
||||||
condition : cond,
|
condition : cond,
|
||||||
body : body,
|
body : body,
|
||||||
alternative : belse
|
alternative : alt,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2171,9 +2167,9 @@ function parse($TEXT, options) {
|
|||||||
token_error(sym.start, "Unexpected " + sym.name + " in strict mode");
|
token_error(sym.start, "Unexpected " + sym.name + " in strict mode");
|
||||||
}
|
}
|
||||||
|
|
||||||
function as_symbol(type, noerror) {
|
function as_symbol(type, no_error) {
|
||||||
if (!is("name")) {
|
if (!is("name")) {
|
||||||
if (!noerror) croak("Name expected");
|
if (!no_error) croak("Name expected");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var sym = _make_symbol(type, S.token);
|
var sym = _make_symbol(type, S.token);
|
||||||
@@ -2409,20 +2405,20 @@ function parse($TEXT, options) {
|
|||||||
return new ctor({ operator: op, expression: expr });
|
return new ctor({ operator: op, expression: expr });
|
||||||
}
|
}
|
||||||
|
|
||||||
var expr_op = function(left, min_prec, no_in) {
|
var expr_op = function(left, min_precision, no_in) {
|
||||||
var op = is("operator") ? S.token.value : null;
|
var op = is("operator") ? S.token.value : null;
|
||||||
if (op == "in" && no_in) op = null;
|
if (op == "in" && no_in) op = null;
|
||||||
var prec = op != null ? PRECEDENCE[op] : null;
|
var precision = op != null ? PRECEDENCE[op] : null;
|
||||||
if (prec != null && prec > min_prec) {
|
if (precision != null && precision > min_precision) {
|
||||||
next();
|
next();
|
||||||
var right = expr_op(maybe_unary(no_in), op == "**" ? prec - 1 : prec, no_in);
|
var right = expr_op(maybe_unary(no_in), op == "**" ? precision - 1 : precision, no_in);
|
||||||
return expr_op(new AST_Binary({
|
return expr_op(new AST_Binary({
|
||||||
start : left.start,
|
start : left.start,
|
||||||
left : left,
|
left : left,
|
||||||
operator : op,
|
operator : op,
|
||||||
right : right,
|
right : right,
|
||||||
end : right.end
|
end : right.end,
|
||||||
}), min_prec, no_in);
|
}), min_precision, no_in);
|
||||||
}
|
}
|
||||||
return left;
|
return left;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ function mangle_properties(ast, options) {
|
|||||||
var regex = options.regex;
|
var regex = options.regex;
|
||||||
|
|
||||||
// note debug is either false (disabled), or a string of the debug suffix to use (enabled).
|
// note debug is either false (disabled), or a string of the debug suffix to use (enabled).
|
||||||
// note debug may be enabled as an empty string, which is falsey. Also treat passing 'true'
|
// note debug may be enabled as an empty string, which is falsy. Also treat passing 'true'
|
||||||
// the same as passing an empty string.
|
// the same as passing an empty string.
|
||||||
var debug = options.debug !== false;
|
var debug = options.debug !== false;
|
||||||
var debug_suffix;
|
var debug_suffix;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ concat_1: {
|
|||||||
|
|
||||||
var e = 1 + x() + 2 + "X" + 3 + "boo";
|
var e = 1 + x() + 2 + "X" + 3 + "boo";
|
||||||
|
|
||||||
// be careful with concatentation with "\0" with octal-looking strings.
|
// be careful with concatenation with "\0" with octal-looking strings.
|
||||||
var f = "\0" + 360 + "\0" + 8 + "\0";
|
var f = "\0" + 360 + "\0" + 8 + "\0";
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
|
|||||||
@@ -525,7 +525,7 @@ if_var_return_2: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if_var_retrn_3: {
|
if_var_return_3: {
|
||||||
options = {
|
options = {
|
||||||
conditionals: true,
|
conditionals: true,
|
||||||
if_return: true,
|
if_return: true,
|
||||||
|
|||||||
@@ -140,12 +140,12 @@ mangle: {
|
|||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
import foo, { bar } from "baz";
|
import foo, { bar } from "baz";
|
||||||
consoe.log(moo);
|
console.log(moo);
|
||||||
import * as moo from "moz";
|
import * as moo from "moz";
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
import o, { bar as m } from "baz";
|
import o, { bar as m } from "baz";
|
||||||
consoe.log(r);
|
console.log(r);
|
||||||
import * as r from "moz";
|
import * as r from "moz";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -157,12 +157,12 @@ rename_mangle: {
|
|||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
import foo, { bar } from "baz";
|
import foo, { bar } from "baz";
|
||||||
consoe.log(moo);
|
console.log(moo);
|
||||||
import * as moo from "moz";
|
import * as moo from "moz";
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
import o, { bar as m } from "baz";
|
import o, { bar as m } from "baz";
|
||||||
consoe.log(r);
|
console.log(r);
|
||||||
import * as r from "moz";
|
import * as r from "moz";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* There was an incorrect sort behaviour documented in issue #143:
|
* There was an incorrect sort behavior documented in issue #143:
|
||||||
* (x = f(…)) <= x → x >= (x = f(…))
|
* (x = f(…)) <= x → x >= (x = f(…))
|
||||||
*
|
*
|
||||||
* For example, let the equation be:
|
* For example, let the equation be:
|
||||||
@@ -12,37 +12,54 @@
|
|||||||
* a >= (a = parseInt('100')) → 99 >= 100 → false
|
* a >= (a = parseInt('100')) → 99 >= 100 → false
|
||||||
*/
|
*/
|
||||||
|
|
||||||
tranformation_sort_order_equal: {
|
transformation_sort_order_equal: {
|
||||||
options = {
|
options = {
|
||||||
comparisons: true,
|
comparisons: true,
|
||||||
}
|
}
|
||||||
|
input: {
|
||||||
input: { (a = parseInt('100')) == a }
|
console.log((a = parseInt("100")) == a);
|
||||||
expect: { (a = parseInt('100')) == a }
|
}
|
||||||
|
expect: {
|
||||||
|
console.log((a = parseInt("100")) == a);
|
||||||
|
}
|
||||||
|
expect_stdout: "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
tranformation_sort_order_unequal: {
|
transformation_sort_order_unequal: {
|
||||||
options = {
|
options = {
|
||||||
comparisons: true,
|
comparisons: true,
|
||||||
}
|
}
|
||||||
|
input: {
|
||||||
input: { (a = parseInt('100')) != a }
|
console.log((a = parseInt("100")) != a);
|
||||||
expect: { (a = parseInt('100')) != a }
|
}
|
||||||
|
expect: {
|
||||||
|
console.log((a = parseInt("100")) != a);
|
||||||
|
}
|
||||||
|
expect_stdout: "false"
|
||||||
}
|
}
|
||||||
|
|
||||||
tranformation_sort_order_lesser_or_equal: {
|
transformation_sort_order_lesser_or_equal: {
|
||||||
options = {
|
options = {
|
||||||
comparisons: true,
|
comparisons: true,
|
||||||
}
|
}
|
||||||
|
input: {
|
||||||
input: { (a = parseInt('100')) <= a }
|
console.log((a = parseInt("100")) <= a);
|
||||||
expect: { (a = parseInt('100')) <= a }
|
}
|
||||||
|
expect: {
|
||||||
|
console.log((a = parseInt("100")) <= a);
|
||||||
|
}
|
||||||
|
expect_stdout: "true"
|
||||||
}
|
}
|
||||||
tranformation_sort_order_greater_or_equal: {
|
|
||||||
|
transformation_sort_order_greater_or_equal: {
|
||||||
options = {
|
options = {
|
||||||
comparisons: true,
|
comparisons: true,
|
||||||
}
|
}
|
||||||
|
input: {
|
||||||
input: { (a = parseInt('100')) >= a }
|
console.log((a = parseInt("100")) >= a);
|
||||||
expect: { (a = parseInt('100')) >= a }
|
}
|
||||||
|
expect: {
|
||||||
|
console.log((a = parseInt("100")) >= a);
|
||||||
|
}
|
||||||
|
expect_stdout: "true"
|
||||||
}
|
}
|
||||||
@@ -15,7 +15,7 @@ collapse: {
|
|||||||
var a;
|
var a;
|
||||||
b = c();
|
b = c();
|
||||||
a = typeof b === 'function' ? b() : b;
|
a = typeof b === 'function' ? b() : b;
|
||||||
return 'stirng' == typeof a && d();
|
return 'string' == typeof a && d();
|
||||||
}
|
}
|
||||||
function f3(c) {
|
function f3(c) {
|
||||||
var a;
|
var a;
|
||||||
@@ -41,7 +41,7 @@ collapse: {
|
|||||||
return void 0 !== ('function' === typeof b ? b() : b) && c();
|
return void 0 !== ('function' === typeof b ? b() : b) && c();
|
||||||
}
|
}
|
||||||
function f2(b) {
|
function f2(b) {
|
||||||
return 'stirng' == typeof ('function' === typeof (b = c()) ? b() : b) && d();
|
return 'string' == typeof ('function' === typeof (b = c()) ? b() : b) && d();
|
||||||
}
|
}
|
||||||
function f3(c) {
|
function f3(c) {
|
||||||
var a;
|
var a;
|
||||||
|
|||||||
@@ -570,7 +570,7 @@ inlined_assignments: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
inilne_for: {
|
inline_for: {
|
||||||
options = {
|
options = {
|
||||||
inline: true,
|
inline: true,
|
||||||
join_vars: true,
|
join_vars: true,
|
||||||
@@ -590,7 +590,7 @@ inilne_for: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
inilne_var: {
|
inline_var: {
|
||||||
options = {
|
options = {
|
||||||
inline: true,
|
inline: true,
|
||||||
join_vars: true,
|
join_vars: true,
|
||||||
|
|||||||
@@ -400,7 +400,7 @@ describe("comments", function() {
|
|||||||
assert.strictEqual(ast.print_to_string({comments: "all"}), "/*!test1*/\n/*test2*/\n//!test3\n//test4\n//test5\n//!test6\n//test7\n//!test8");
|
assert.strictEqual(ast.print_to_string({comments: "all"}), "/*!test1*/\n/*test2*/\n//!test3\n//test4\n//test5\n//!test6\n//test7\n//!test8");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should be able to filter commments with the 'some' option", function() {
|
it("Should be able to filter comments with the 'some' option", function() {
|
||||||
var ast = UglifyJS.parse("// foo\n/*@preserve*/\n// bar\n/*@license*/\n//@license with the wrong comment type\n/*@cc_on something*/");
|
var ast = UglifyJS.parse("// foo\n/*@preserve*/\n// bar\n/*@license*/\n//@license with the wrong comment type\n/*@cc_on something*/");
|
||||||
assert.strictEqual(ast.print_to_string({comments: "some"}), "/*@preserve*/\n/*@license*/\n/*@cc_on something*/");
|
assert.strictEqual(ast.print_to_string({comments: "some"}), "/*@preserve*/\n/*@license*/\n/*@cc_on something*/");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -348,7 +348,7 @@ describe("Directives", function() {
|
|||||||
'"use strict";doSomething("foo");'
|
'"use strict";doSomething("foo");'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
// Nothing gets optimised in the compressor because "use asm" is the first statement
|
// Nothing gets optimized in the compressor because "use asm" is the first statement
|
||||||
'"use asm";"use\\x20strict";1+1;',
|
'"use asm";"use\\x20strict";1+1;',
|
||||||
'"use asm";"use\\x20strict";1+1;'
|
'"use asm";"use\\x20strict";1+1;'
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ describe("sourcemaps", function() {
|
|||||||
if (result.error) throw result.error;
|
if (result.error) throw result.error;
|
||||||
assert.strictEqual(result.code + "\n", read("test/input/issue-3294/output.js"));
|
assert.strictEqual(result.code + "\n", read("test/input/issue-3294/output.js"));
|
||||||
});
|
});
|
||||||
it("Should work in presence of unrecognised annotations", function() {
|
it("Should work in presence of unrecognized annotations", function() {
|
||||||
var result = UglifyJS.minify(read("test/input/issue-3441/input.js"), {
|
var result = UglifyJS.minify(read("test/input/issue-3441/input.js"), {
|
||||||
compress: false,
|
compress: false,
|
||||||
mangle: false,
|
mangle: false,
|
||||||
|
|||||||
@@ -1142,7 +1142,7 @@ function createStatement(recurmax, canThrow, canBreak, canContinue, cannotReturn
|
|||||||
}
|
}
|
||||||
case STMT_FUNC_EXPR:
|
case STMT_FUNC_EXPR:
|
||||||
// "In non-strict mode code, functions can only be declared at top level, inside a block, or ..."
|
// "In non-strict mode code, functions can only be declared at top level, inside a block, or ..."
|
||||||
// (dont both with func decls in `if`; it's only a parser thing because you cant call them without a block)
|
// (don't make func decls in `if`; it's only a parser thing because you can't call them without a block)
|
||||||
return "{" + createFunction(recurmax, NO_DEFUN, canThrow, stmtDepth) + "}";
|
return "{" + createFunction(recurmax, NO_DEFUN, canThrow, stmtDepth) + "}";
|
||||||
case STMT_TRY:
|
case STMT_TRY:
|
||||||
// catch var could cause some problems
|
// catch var could cause some problems
|
||||||
|
|||||||
Reference in New Issue
Block a user