aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-11-10 05:47:10 +0800
committerGitHub <noreply@github.com>2017-11-10 05:47:10 +0800
commit94525d859f5db559366f96b646aca84438b0f982 (patch)
treefc9aa27f6e2e8dea8c441308d2ac51f1c4586ba9 /lib
parent1127a2caf305ad1df370c34faf7283e53423cc10 (diff)
downloadtracifyjs-94525d859f5db559366f96b646aca84438b0f982.tar.gz
tracifyjs-94525d859f5db559366f96b646aca84438b0f982.zip
fix object literal tracing in `reduce_vars` (#2461)
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/compress.js b/lib/compress.js
index d915e23e..24c5be21 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -609,8 +609,11 @@ merge(Compressor.prototype, {
&& parent.expression === node
&& (!(value instanceof AST_Function) || value.contains_this(parent))) {
return true;
- } else if (parent instanceof AST_Array || parent instanceof AST_Object) {
+ } else if (parent instanceof AST_Array) {
return is_modified(parent, parent, level + 1);
+ } else if (parent instanceof AST_ObjectKeyVal && node === parent.value) {
+ var obj = tw.parent(level + 1);
+ return is_modified(obj, obj, level + 2);
} else if (parent instanceof AST_PropAccess && parent.expression === node) {
return !immutable && is_modified(parent, read_property(value, parent.property), level + 1);
}
@@ -626,8 +629,11 @@ merge(Compressor.prototype, {
|| parent instanceof AST_VarDef && node === parent.value) {
d.escaped = true;
return;
- } else if (parent instanceof AST_Array || parent instanceof AST_Object) {
+ } else if (parent instanceof AST_Array) {
mark_escaped(d, parent, parent, level + 1);
+ } else if (parent instanceof AST_ObjectKeyVal && node === parent.value) {
+ var obj = tw.parent(level + 1);
+ mark_escaped(d, obj, obj, level + 2);
} else if (parent instanceof AST_PropAccess && node === parent.expression) {
value = read_property(value, parent.property);
mark_escaped(d, parent, value, level + 1);