From b1b088a128c738f6bb51d203cf523795ed77ee9c Mon Sep 17 00:00:00 2001 From: kzc Date: Wed, 6 Sep 2017 13:47:06 -0400 Subject: [PATCH] add even more known globals to `unsafe` option --- lib/compress.js | 2 +- test/compress/dead-code.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/compress.js b/lib/compress.js index 45cc79e5..3da7a315 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -693,7 +693,7 @@ merge(Compressor.prototype, { return node instanceof AST_SymbolRef && node.definition().undeclared; } - var global_names = makePredicate("Array Boolean console Date Error EvalError Function JSON Math Number parseInt RangeError ReferenceError RegExp Object String SyntaxError TypeError URIError"); + var global_names = makePredicate("Array Boolean clearInterval clearTimeout console Date decodeURI decodeURIComponent encodeURI encodeURIComponent Error escape eval EvalError Function isFinite isNaN JSON Math Number parseFloat parseInt RangeError ReferenceError RegExp Object setInterval setTimeout String SyntaxError TypeError unescape URIError"); AST_SymbolRef.DEFMETHOD("is_declared", function(compressor) { return !this.definition().undeclared || compressor.option("unsafe") && global_names(this.name); diff --git a/test/compress/dead-code.js b/test/compress/dead-code.js index 6ae368fa..ad8fc8e5 100644 --- a/test/compress/dead-code.js +++ b/test/compress/dead-code.js @@ -240,22 +240,36 @@ issue_2233_1: { input: { Array.isArray; Boolean; + //clearInterval; + //clearTimeout; console.log; Date; + decodeURI; + decodeURIComponent; + encodeURI; + encodeURIComponent; Error.name; + escape; + eval; EvalError; Function.length; + isFinite; + isNaN; JSON; Math.random; Number.isNaN; + parseFloat; parseInt; RegExp; Object.defineProperty; String.fromCharCode; RangeError; ReferenceError; + //setInterval; + //setTimeout; SyntaxError; TypeError; + unescape; URIError; } expect: {}