diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-11-25 22:52:46 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-25 22:52:46 +0800 |
commit | c141ae6f8dcfa058f03ae3580275c87b564b77a3 (patch) | |
tree | 28158152aed32b9cd5ed86528b6687c3e20f5b5a /lib/compress.js | |
parent | 97c464dbf5aec124cba9cfeedb896fa97818622c (diff) | |
download | tracifyjs-c141ae6f8dcfa058f03ae3580275c87b564b77a3.tar.gz tracifyjs-c141ae6f8dcfa058f03ae3580275c87b564b77a3.zip |
fix argument/atom collision by `properties` (#2514)
fixes #2513
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/compress.js b/lib/compress.js index 744a1ea5..22415f4d 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -4708,6 +4708,17 @@ merge(Compressor.prototype, { if (compressor.option("properties")) { var key = prop.evaluate(compressor); if (key !== prop) { + if (typeof key == "string") { + if (key == "undefined") { + key = undefined; + } else { + var value = parseFloat(key); + if (value.toString() == key) { + key = value; + } + } + } + prop = self.property = best_of_expression(prop, make_node_from_constant(key, prop).transform(compressor)); var property = "" + key; if (is_identifier_string(property) && property.length <= prop.print_to_string().length + 1) { @@ -4716,14 +4727,6 @@ merge(Compressor.prototype, { property: property }).optimize(compressor); } - if (!(prop instanceof AST_Number)) { - var value = parseFloat(property); - if (value.toString() == property) { - prop = self.property = make_node(AST_Number, prop, { - value: value - }); - } - } } } if (is_lhs(self, compressor.parent())) return self; |