Mangle class names correctly

This commit is contained in:
Fábio Santos
2015-11-21 13:59:18 +00:00
parent 425613b0d2
commit e076abdbf2
2 changed files with 25 additions and 2 deletions

View File

@@ -66,7 +66,11 @@ SymbolDef.prototype = {
|| (!options.eval && (this.scope.uses_eval || this.scope.uses_with))
|| (options.keep_fnames
&& (this.orig[0] instanceof AST_SymbolLambda
|| this.orig[0] instanceof AST_SymbolDefun));
|| this.orig[0] instanceof AST_SymbolDefun))
|| this.orig[0] instanceof AST_SymbolMethod
|| (options.keep_classnames
&& (this.orig[0] instanceof AST_SymbolClass
|| this.orig[0] instanceof AST_SymbolDefClass));
},
mangle: function(options) {
var cache = options.cache && options.cache.props;
@@ -379,7 +383,8 @@ AST_Toplevel.DEFMETHOD("_default_mangler_options", function(options){
sort : false,
toplevel : false,
screw_ie8 : false,
keep_fnames : false
keep_fnames : false,
keep_classnames : false
});
});

View File

@@ -233,6 +233,24 @@ class_name_can_be_mangled: {
}
}
class_name_can_be_preserved: {
mangle = {
keep_classnames: true
}
input: {
function x() {
(class Baz { });
class Foo {};
}
}
expect: {
function x() {
(class Baz { });
class Foo {};
}
}
}
number_literals: {
input: {
0b1001;