aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-10-27 02:33:37 +0800
committerGitHub <noreply@github.com>2017-10-27 02:33:37 +0800
commit9b0f86f5a136f57dece826c3ec9b632a0d0cb53a (patch)
treef0376084874be83dac2585b51592241cd33fba68 /lib
parentee082ace1b69bff228ff43065333b8703c0505dc (diff)
downloadtracifyjs-9b0f86f5a136f57dece826c3ec9b632a0d0cb53a.tar.gz
tracifyjs-9b0f86f5a136f57dece826c3ec9b632a0d0cb53a.zip
fix `reduce_vars` on `AST_Array.length` (#2404)
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 073399b5..a2dd243f 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -572,7 +572,9 @@ merge(Compressor.prototype, {
if (key instanceof AST_Node) return null;
var value;
if (obj instanceof AST_Array) {
- value = obj.elements[key];
+ var elements = obj.elements;
+ if (key == "length") return make_node_from_constant(elements.length, obj);
+ if (typeof key == "number" && key in elements) value = elements[key];
} else if (obj instanceof AST_Object) {
var props = obj.properties;
for (var i = props.length; --i >= 0;) {