diff options
Diffstat (limited to 'lib/propmangle.js')
-rw-r--r-- | lib/propmangle.js | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/propmangle.js b/lib/propmangle.js index 254780f9..e7dc5097 100644 --- a/lib/propmangle.js +++ b/lib/propmangle.js @@ -81,7 +81,9 @@ var builtins = function() { function reserve_quoted_keys(ast, reserved) { ast.walk(new TreeWalker(function(node) { - if (node instanceof AST_ObjectProperty) { + if (node instanceof AST_ClassProperty) { + if (node.start && node.start.quote) add(node.key); + } else if (node instanceof AST_ObjectProperty) { if (node.start && node.start.quote) add(node.key); } else if (node instanceof AST_Sub) { addStrings(node.property, add); @@ -163,6 +165,8 @@ function mangle_properties(ast, options) { addStrings(node.args[0], add); break; } + } else if (node instanceof AST_ClassProperty) { + if (typeof node.key == "string") add(node.key); } else if (node instanceof AST_Dot) { add(node.property); } else if (node instanceof AST_ObjectProperty) { @@ -193,6 +197,8 @@ function mangle_properties(ast, options) { mangleStrings(node.args[0]); break; } + } else if (node instanceof AST_ClassProperty) { + if (typeof node.key == "string") node.key = mangle(node.key); } else if (node instanceof AST_Dot) { node.property = mangle(node.property); } else if (node instanceof AST_ObjectProperty) { @@ -222,9 +228,7 @@ function mangle_properties(ast, options) { } function mangle(name) { - if (!should_mangle(name)) { - return name; - } + if (!should_mangle(name)) return name; var mangled = cache.get(name); if (!mangled) { if (debug) { @@ -236,6 +240,7 @@ function mangle_properties(ast, options) { if (!mangled) do { mangled = base54(++cname); } while (!can_mangle(mangled)); + if (/^#/.test(name)) mangled = "#" + mangled; cache.set(name, mangled); } return mangled; |