fix unknown property access
This commit is contained in:
parent
1893abd2cb
commit
cf75ccbce9
|
|
@ -611,8 +611,9 @@ merge(Compressor.prototype, {
|
|||
} else if (parent instanceof AST_Array || parent instanceof AST_Object) {
|
||||
mark_escaped(d, parent, parent, level + 1);
|
||||
} else if (parent instanceof AST_PropAccess && node === parent.expression) {
|
||||
mark_escaped(d, parent, read_property(value, parent.property), level + 1);
|
||||
return;
|
||||
value = read_property(value, parent.property);
|
||||
mark_escaped(d, parent, value, level + 1);
|
||||
if (value) return;
|
||||
}
|
||||
if (level == 0) d.direct_access = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ issue_2377_3: {
|
|||
expect_stdout: "1 27"
|
||||
}
|
||||
|
||||
direct_access: {
|
||||
direct_access_1: {
|
||||
options = {
|
||||
reduce_vars: true,
|
||||
hoist_props: true,
|
||||
|
|
@ -129,6 +129,55 @@ direct_access: {
|
|||
expect_stdout: "2 1"
|
||||
}
|
||||
|
||||
direct_access_2: {
|
||||
options = {
|
||||
reduce_vars: true,
|
||||
hoist_props: true,
|
||||
toplevel: true,
|
||||
unused: true,
|
||||
}
|
||||
mangle = {
|
||||
toplevel: true,
|
||||
}
|
||||
input: {
|
||||
var o = { a: 1 };
|
||||
var f = function(k) {
|
||||
if (o[k]) return "PASS";
|
||||
};
|
||||
console.log(f("a"));
|
||||
}
|
||||
expect: {
|
||||
var n = { a: 1 };
|
||||
console.log(function(o) {
|
||||
if (n[o]) return "PASS";
|
||||
}("a"));
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
direct_access_3: {
|
||||
options = {
|
||||
reduce_vars: true,
|
||||
hoist_props: true,
|
||||
toplevel: true,
|
||||
unused: true,
|
||||
}
|
||||
mangle = {
|
||||
toplevel: true,
|
||||
}
|
||||
input: {
|
||||
var o = { a: 1 };
|
||||
o.b;
|
||||
console.log(o.a);
|
||||
}
|
||||
expect: {
|
||||
var a = { a: 1 };
|
||||
a.b;
|
||||
console.log(a.a);
|
||||
}
|
||||
expect_stdout: "1"
|
||||
}
|
||||
|
||||
single_use: {
|
||||
options = {
|
||||
reduce_vars: true,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user