aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-07-14 19:52:01 +0800
committerGitHub <noreply@github.com>2017-07-14 19:52:01 +0800
commit9282e7b0c6f20bc95ba3d2bab2bbaccebab03c9a (patch)
tree23035ef62454c2bcbc06bd12a36c499b75c6d187
parent5229cb2b1b345a4cedbdeacb02f114033f4c69b7 (diff)
downloadtracifyjs-9282e7b0c6f20bc95ba3d2bab2bbaccebab03c9a.tar.gz
tracifyjs-9282e7b0c6f20bc95ba3d2bab2bbaccebab03c9a.zip
fix `unsafe` `evaluate` of `Object` static methods (#2232)
fixes #2231
-rw-r--r--lib/compress.js8
-rw-r--r--test/compress/evaluate.js28
2 files changed, 31 insertions, 5 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 3a5694fc..0330c682 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -1853,10 +1853,6 @@ merge(Compressor.prototype, {
"isFinite",
"isNaN",
],
- Object: [
- "keys",
- "getOwnPropertyNames",
- ],
String: [
"fromCharCode",
],
@@ -3496,7 +3492,9 @@ merge(Compressor.prototype, {
operator: car.operator,
expression: left
});
- } else car.write_only = false;
+ } else {
+ car.write_only = false;
+ }
if (parent) {
parent[field] = car;
expressions[i] = expressions[j];
diff --git a/test/compress/evaluate.js b/test/compress/evaluate.js
index 38e9cdcb..1c737060 100644
--- a/test/compress/evaluate.js
+++ b/test/compress/evaluate.js
@@ -1157,3 +1157,31 @@ issue_2207_3: {
}
expect_stdout: true
}
+
+issue_2231_1: {
+ options = {
+ evaluate: true,
+ unsafe: true,
+ }
+ input: {
+ console.log(Object.keys(void 0));
+ }
+ expect: {
+ console.log(Object.keys(void 0));
+ }
+ expect_stdout: true
+}
+
+issue_2231_2: {
+ options = {
+ evaluate: true,
+ unsafe: true,
+ }
+ input: {
+ console.log(Object.getOwnPropertyNames(null));
+ }
+ expect: {
+ console.log(Object.getOwnPropertyNames(null));
+ }
+ expect_stdout: true
+}