uglify-js
Advanced tools
Comparing version 3.7.7 to 3.8.0
@@ -172,6 +172,3 @@ /*********************************************************************** | ||
function walk_body(node, visitor) { | ||
var body = node.body; | ||
if (body instanceof AST_Statement) { | ||
body._walk(visitor); | ||
} else body.forEach(function(node) { | ||
node.body.forEach(function(node) { | ||
node._walk(visitor); | ||
@@ -355,3 +352,3 @@ }); | ||
if (node instanceof AST_Directive && node.value == "$ORIG") { | ||
return MAP.splice(body); | ||
return List.splice(body); | ||
} | ||
@@ -375,3 +372,3 @@ })); | ||
if (node instanceof AST_Directive && node.value == "$ORIG") { | ||
return MAP.splice(body); | ||
return List.splice(body); | ||
} | ||
@@ -378,0 +375,0 @@ })); |
@@ -786,2 +786,4 @@ /*********************************************************************** | ||
var value = this.value; | ||
// https://github.com/mishoo/UglifyJS2/issues/115 | ||
// https://github.com/mishoo/UglifyJS2/pull/1009 | ||
if (value < 0 || /^0/.test(make_num(value))) { | ||
@@ -1356,7 +1358,14 @@ return true; | ||
var str = regexp.toString(); | ||
var end = str.lastIndexOf("/"); | ||
if (regexp.raw_source) { | ||
str = "/" + regexp.raw_source + str.slice(str.lastIndexOf("/")); | ||
str = "/" + regexp.raw_source + str.slice(end); | ||
} else if (end == 1) { | ||
str = "/(?:)" + str.slice(end); | ||
} else if (str.indexOf("/", 1) < end) { | ||
str = "/" + str.slice(1, end).replace(/\\\\|[^/]?\//g, function(match) { | ||
return match[0] == "\\" ? match : match.slice(0, -1) + "\\/"; | ||
}) + str.slice(end); | ||
} | ||
output.print(output.to_utf8(str).replace(/\\(?:\0(?![0-9])|[^\0])/g, function(seq) { | ||
switch (seq[1]) { | ||
output.print(output.to_utf8(str).replace(/\\(?:\0(?![0-9])|[^\0])/g, function(match) { | ||
switch (match[1]) { | ||
case "\n": return "\\n"; | ||
@@ -1371,3 +1380,3 @@ case "\r": return "\\r"; | ||
case "\u2029": return "\\u2029"; | ||
default: return seq; | ||
default: return match; | ||
} | ||
@@ -1374,0 +1383,0 @@ }).replace(/[\n\r\u2028\u2029]/g, function(c) { |
@@ -55,3 +55,3 @@ /*********************************************************************** | ||
function do_list(list, tw) { | ||
return MAP(list, function(node) { | ||
return List(list, function(node) { | ||
return node.transform(tw, true); | ||
@@ -58,0 +58,0 @@ }); |
@@ -116,4 +116,4 @@ /*********************************************************************** | ||
var MAP = (function() { | ||
function MAP(a, f, backwards) { | ||
var List = (function() { | ||
function List(a, f, backwards) { | ||
var ret = [], top = [], i; | ||
@@ -153,10 +153,10 @@ function doit() { | ||
} | ||
MAP.at_top = function(val) { return new AtTop(val) }; | ||
MAP.splice = function(val) { return new Splice(val) }; | ||
MAP.last = function(val) { return new Last(val) }; | ||
var skip = MAP.skip = {}; | ||
function AtTop(val) { this.v = val } | ||
function Splice(val) { this.v = val } | ||
function Last(val) { this.v = val } | ||
return MAP; | ||
List.at_top = function(val) { return new AtTop(val); }; | ||
List.splice = function(val) { return new Splice(val); }; | ||
List.last = function(val) { return new Last(val); }; | ||
var skip = List.skip = {}; | ||
function AtTop(val) { this.v = val; } | ||
function Splice(val) { this.v = val; } | ||
function Last(val) { this.v = val; } | ||
return List; | ||
})(); | ||
@@ -163,0 +163,0 @@ |
@@ -6,3 +6,3 @@ { | ||
"license": "BSD-2-Clause", | ||
"version": "3.7.7", | ||
"version": "3.8.0", | ||
"engines": { | ||
@@ -9,0 +9,0 @@ "node": ">=0.8.0" |
@@ -851,4 +851,10 @@ UglifyJS 3 | ||
- `comments` (default `false`) -- pass `true` or `"all"` to preserve all | ||
comments, `"some"` to preserve some comments, a regular expression string | ||
(e.g. `/^!/`) or a function. | ||
comments, `"some"` to preserve multi-line comments that contain `@cc_on`, | ||
`@license`, or `@preserve` (case-insensitive), a regular expression string | ||
(e.g. `/^!/`), or a function which returns `boolean`, e.g. | ||
```js | ||
function(node, comment) { | ||
return comment.value.indexOf("@type " + node.TYPE) >= 0; | ||
} | ||
``` | ||
@@ -855,0 +861,0 @@ - `indent_level` (default `4`) |
exports["Dictionary"] = Dictionary; | ||
exports["List"] = List; | ||
exports["minify"] = minify; | ||
@@ -3,0 +4,0 @@ exports["parse"] = parse; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
801365
20482
1153