Do not mangle a name if it is in a destructuring vardef.
This commit is contained in:
parent
a3a4ae5ef8
commit
d757202b74
16
lib/scope.js
16
lib/scope.js
|
|
@ -98,7 +98,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
|
|||
var defun = null;
|
||||
var last_var_had_const_pragma = false;
|
||||
var nesting = 0;
|
||||
var object_destructuring_arg = false;
|
||||
var in_destructuring = null;
|
||||
var tw = new TreeWalker(function(node, descend){
|
||||
if (options.screw_ie8 && node instanceof AST_Catch) {
|
||||
var save_scope = scope;
|
||||
|
|
@ -110,9 +110,9 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
|
|||
return true;
|
||||
}
|
||||
if (node instanceof AST_Destructuring && node.is_array === false) {
|
||||
object_destructuring_arg = true; // These don't nest
|
||||
in_destructuring = node; // These don't nest
|
||||
descend();
|
||||
object_destructuring_arg = false;
|
||||
in_destructuring = null;
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_Scope) {
|
||||
|
|
@ -151,7 +151,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
|
|||
node.references = [];
|
||||
}
|
||||
if (node instanceof AST_SymbolFunarg) {
|
||||
node.object_destructuring_arg = object_destructuring_arg;
|
||||
node.object_destructuring_arg = !!in_destructuring;
|
||||
defun.def_variable(node);
|
||||
}
|
||||
if (node instanceof AST_SymbolLambda) {
|
||||
|
|
@ -171,7 +171,8 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
|
|||
else if (node instanceof AST_SymbolVar
|
||||
|| node instanceof AST_SymbolConst) {
|
||||
var def = defun.def_variable(node);
|
||||
def.constant = node instanceof AST_SymbolConst || last_var_had_const_pragma;
|
||||
def.constant = node instanceof AST_SymbolConst;
|
||||
def.destructuring = in_destructuring;
|
||||
def.init = tw.parent().value;
|
||||
}
|
||||
else if (node instanceof AST_SymbolCatch) {
|
||||
|
|
@ -458,7 +459,10 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options){
|
|||
}
|
||||
});
|
||||
this.walk(tw);
|
||||
to_mangle.forEach(function(def){ def.mangle(options) });
|
||||
to_mangle.forEach(function(def){
|
||||
if (def.destructuring && !def.destructuring.is_array) return;
|
||||
def.mangle(options);
|
||||
});
|
||||
|
||||
if (options.cache) {
|
||||
options.cache.cname = this.cname;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user