fix a couple of bugs in global_defs
- `optimize()` substituted expression - compute nested property string correctly fixes #1801
This commit is contained in:
parent
a1532eb076
commit
9c17f2f5e3
|
|
@ -1346,7 +1346,7 @@ merge(Compressor.prototype, {
|
|||
}
|
||||
def(AST_Node, noop);
|
||||
def(AST_Dot, function(compressor, suffix){
|
||||
return this.expression._find_defs(compressor, suffix + "." + this.property);
|
||||
return this.expression._find_defs(compressor, "." + this.property + suffix);
|
||||
});
|
||||
def(AST_SymbolRef, function(compressor, suffix){
|
||||
if (!this.global()) return;
|
||||
|
|
@ -3566,7 +3566,7 @@ merge(Compressor.prototype, {
|
|||
OPT(AST_SymbolRef, function(self, compressor){
|
||||
var def = self.resolve_defines(compressor);
|
||||
if (def) {
|
||||
return def;
|
||||
return def.optimize(compressor);
|
||||
}
|
||||
// testing against !self.scope.uses_with first is an optimization
|
||||
if (compressor.option("screw_ie8")
|
||||
|
|
@ -3916,7 +3916,7 @@ merge(Compressor.prototype, {
|
|||
OPT(AST_Dot, function(self, compressor){
|
||||
var def = self.resolve_defines(compressor);
|
||||
if (def) {
|
||||
return def;
|
||||
return def.optimize(compressor);
|
||||
}
|
||||
var prop = self.property;
|
||||
if (RESERVED_WORDS(prop) && !compressor.option("screw_ie8")) {
|
||||
|
|
|
|||
|
|
@ -145,3 +145,18 @@ mixed: {
|
|||
'WARN: global_defs CONFIG.VALUE redefined [test/compress/global_defs.js:129,8]',
|
||||
]
|
||||
}
|
||||
|
||||
issue_1801: {
|
||||
options = {
|
||||
booleans: true,
|
||||
global_defs: {
|
||||
"CONFIG.FOO.BAR": true,
|
||||
},
|
||||
}
|
||||
input: {
|
||||
console.log(CONFIG.FOO.BAR);
|
||||
}
|
||||
expect: {
|
||||
console.log(!0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user