diff --git a/lib/propmangle.js b/lib/propmangle.js index 0a84b83b..50967887 100644 --- a/lib/propmangle.js +++ b/lib/propmangle.js @@ -103,9 +103,13 @@ function mangle_properties(ast, options) { var ignore_quoted = options.ignore_quoted; // 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_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 unmangleable = []; diff --git a/test/compress/properties.js b/test/compress/properties.js index 554dd4d2..5598b45d 100644 --- a/test/compress/properties.js +++ b/test/compress/properties.js @@ -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_props = { debug: "XYZ"