Treat debug: true debug: ""

Supports passing `true` for `debug` in `mangle_properties`. Added test
case to verify this behavior.
This commit is contained in:
Ashley (Scirra) 2016-10-07 16:11:58 +01:00
parent 65922fcbb2
commit 1e19cd08fa
2 changed files with 20 additions and 2 deletions

View File

@ -103,9 +103,13 @@ function mangle_properties(ast, options) {
var ignore_quoted = options.ignore_quoted; var ignore_quoted = options.ignore_quoted;
// note debug is either false (disabled), or a string of the debug suffix to use (enabled). // note debug is either false (disabled), or a string of the debug suffix to use (enabled).
// note debug may be enabled as an empty string, which is falsey. // note debug may be enabled as an empty string, which is falsey. Also treat passing 'true'
// the same as passing an empty string.
var debug = (options.debug !== false); var debug = (options.debug !== false);
var debug_name_suffix = debug ? options.debug : null; var debug_name_suffix;
if (debug) {
debug_name_suffix = (options.debug === true ? "" : options.debug);
}
var names_to_mangle = []; var names_to_mangle = [];
var unmangleable = []; var unmangleable = [];

View File

@ -157,6 +157,20 @@ mangle_debug: {
} }
} }
mangle_debug_true: {
mangle_props = {
debug: true
};
input: {
a.foo = "bar";
x = { baz: "ban" };
}
expect: {
a._$foo$_ = "bar";
x = { _$baz$_: "ban" };
}
}
mangle_debug_suffix: { mangle_debug_suffix: {
mangle_props = { mangle_props = {
debug: "XYZ" debug: "XYZ"