rename illegal_mangled_names to illegalmangled
This commit is contained in:
parent
c7f5c6b36b
commit
d0d37f8e2e
|
|
@ -124,16 +124,16 @@ function mangle_properties(ast, options) {
|
||||||
only_cache : false,
|
only_cache : false,
|
||||||
regex : null,
|
regex : null,
|
||||||
ignore_quoted : false,
|
ignore_quoted : false,
|
||||||
illegal_mangled_names: null,
|
illegalmangled: null,
|
||||||
debug : false
|
debug : false
|
||||||
});
|
});
|
||||||
|
|
||||||
var reserved = options.reserved;
|
var reserved = options.reserved;
|
||||||
if (reserved == null)
|
if (reserved == null)
|
||||||
reserved = find_builtins();
|
reserved = find_builtins();
|
||||||
var illegal_mangled_names = options.illegal_mangled_names;
|
var illegalmangled = options.illegalmangled;
|
||||||
if (illegal_mangled_names == null)
|
if (illegalmangled == null)
|
||||||
illegal_mangled_names = find_js_reserved_words();
|
illegalmangled = find_js_reserved_words();
|
||||||
var cache = options.cache;
|
var cache = options.cache;
|
||||||
if (cache == null) {
|
if (cache == null) {
|
||||||
cache = {
|
cache = {
|
||||||
|
|
@ -158,8 +158,8 @@ function mangle_properties(ast, options) {
|
||||||
var unmangleable = [];
|
var unmangleable = [];
|
||||||
var ignored = {};
|
var ignored = {};
|
||||||
|
|
||||||
if (illegal_mangled_names) {
|
if (illegalmangled) {
|
||||||
unmangleable = unmangleable.concat(illegal_mangled_names);
|
unmangleable = unmangleable.concat(illegalmangled);
|
||||||
}
|
}
|
||||||
// step 1: find candidates to mangle
|
// step 1: find candidates to mangle
|
||||||
ast.walk(new TreeWalker(function(node){
|
ast.walk(new TreeWalker(function(node){
|
||||||
|
|
|
||||||
10
lib/scope.js
10
lib/scope.js
|
|
@ -306,10 +306,10 @@ AST_Scope.DEFMETHOD("def_variable", function(symbol){
|
||||||
|
|
||||||
AST_Scope.DEFMETHOD("next_mangled", function(options){
|
AST_Scope.DEFMETHOD("next_mangled", function(options){
|
||||||
var ext = this.enclosed;
|
var ext = this.enclosed;
|
||||||
var illegal_mangled_names = options.illegal_mangled_names || [];
|
var illegalmangled = options.illegalmangled || [];
|
||||||
out: while (true) {
|
out: while (true) {
|
||||||
var m = base54(++this.cname);
|
var m = base54(++this.cname);
|
||||||
if (illegal_mangled_names.indexOf(m) !== -1) continue; //this name is illegal
|
if (illegalmangled.indexOf(m) !== -1) continue; //this name is illegal
|
||||||
if (!is_identifier(m)) continue; // skip over "do"
|
if (!is_identifier(m)) continue; // skip over "do"
|
||||||
|
|
||||||
// https://github.com/mishoo/UglifyJS2/issues/242 -- do not
|
// https://github.com/mishoo/UglifyJS2/issues/242 -- do not
|
||||||
|
|
@ -397,15 +397,15 @@ AST_Toplevel.DEFMETHOD("_default_mangler_options", function(options){
|
||||||
sort : false, // Ignored. Flag retained for backwards compatibility.
|
sort : false, // Ignored. Flag retained for backwards compatibility.
|
||||||
toplevel : false,
|
toplevel : false,
|
||||||
screw_ie8 : true,
|
screw_ie8 : true,
|
||||||
illegal_mangled_names: null,
|
illegalmangled: null,
|
||||||
keep_fnames : false
|
keep_fnames : false
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
AST_Toplevel.DEFMETHOD("mangle_names", function(options){
|
AST_Toplevel.DEFMETHOD("mangle_names", function(options){
|
||||||
options = this._default_mangler_options(options);
|
options = this._default_mangler_options(options);
|
||||||
if (options.illegal_mangled_names == null)
|
if (options.illegalmangled == null)
|
||||||
options.illegal_mangled_names = find_js_reserved_words();
|
options.illegalmangled = find_js_reserved_words();
|
||||||
// Never mangle arguments
|
// Never mangle arguments
|
||||||
options.except.push('arguments');
|
options.except.push('arguments');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ var assert = require("assert");
|
||||||
var uglify = require("../../");
|
var uglify = require("../../");
|
||||||
|
|
||||||
describe("verify that the mangled names are legal", function () {
|
describe("verify that the mangled names are legal", function () {
|
||||||
it("Should not mangle properties to names in the illegal_mangled_names param", function () {
|
it("Should not mangle properties to names in the illegalmangled param", function () {
|
||||||
var js = 'a["foo"] = "bar"; a.color = "red"; x = {"bar": 10};';
|
var js = 'a["foo"] = "bar"; a.color = "red"; x = {"bar": 10};';
|
||||||
var result = uglify.minify(js, {
|
var result = uglify.minify(js, {
|
||||||
fromString: true,
|
fromString: true,
|
||||||
|
|
@ -14,7 +14,7 @@ describe("verify that the mangled names are legal", function () {
|
||||||
},
|
},
|
||||||
mangleProperties: {
|
mangleProperties: {
|
||||||
ignore_quoted: true,
|
ignore_quoted: true,
|
||||||
illegal_mangled_names: ["a"]
|
illegalmangled: ["a"]
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
keep_quoted_props: true,
|
keep_quoted_props: true,
|
||||||
|
|
@ -24,7 +24,7 @@ describe("verify that the mangled names are legal", function () {
|
||||||
assert.strictEqual(result.code,
|
assert.strictEqual(result.code,
|
||||||
'a["foo"]="bar",a.b="red",x={"bar":10};');
|
'a["foo"]="bar",a.b="red",x={"bar":10};');
|
||||||
});
|
});
|
||||||
it("Should not mangle names to names in the illegal_mangled_names param", function () {
|
it("Should not mangle names to names in the illegalmangled param", function () {
|
||||||
var js = 'var a; a["foo"] = "bar"; a.color = "red"; x = {"bar": 10};';
|
var js = 'var a; a["foo"] = "bar"; a.color = "red"; x = {"bar": 10};';
|
||||||
var result = uglify.minify(js, {
|
var result = uglify.minify(js, {
|
||||||
fromString: true,
|
fromString: true,
|
||||||
|
|
@ -34,7 +34,7 @@ describe("verify that the mangled names are legal", function () {
|
||||||
mangleProperties: {
|
mangleProperties: {
|
||||||
ignore_quoted: true
|
ignore_quoted: true
|
||||||
},
|
},
|
||||||
mangle: {toplevel: true, illegal_mangled_names: ["r", "a"]},
|
mangle: {toplevel: true, illegalmangled: ["r", "a"]},
|
||||||
output: {
|
output: {
|
||||||
keep_quoted_props: true,
|
keep_quoted_props: true,
|
||||||
quote_style: 3
|
quote_style: 3
|
||||||
|
|
@ -43,7 +43,7 @@ describe("verify that the mangled names are legal", function () {
|
||||||
assert.strictEqual(result.code,
|
assert.strictEqual(result.code,
|
||||||
'var b;b["foo"]="bar",b.a="red",x={"bar":10};');
|
'var b;b["foo"]="bar",b.a="red",x={"bar":10};');
|
||||||
});
|
});
|
||||||
it("Should not fail without illegal_mangled_names param", function () {
|
it("Should not fail without illegalmangled param", function () {
|
||||||
var js = 'var b; b["foo"] = "bar"; b.color = "red"; x = {"bar": 10};';
|
var js = 'var b; b["foo"] = "bar"; b.color = "red"; x = {"bar": 10};';
|
||||||
var result = uglify.minify(js, {
|
var result = uglify.minify(js, {
|
||||||
fromString: true,
|
fromString: true,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user