exclude mangling of special property names (#1779)

- `null`
- `true`
- `false`
- numeric literals
This commit is contained in:
Alex Lam S.L
2017-04-04 03:50:19 +08:00
committed by GitHub
parent 48b3fe9952
commit 951770fc68
2 changed files with 91 additions and 39 deletions

View File

@@ -46,6 +46,9 @@
function find_builtins() {
// NaN will be included due to Number.NaN
var a = [
"null",
"true",
"false",
"Infinity",
"-Infinity",
"undefined",
@@ -159,7 +162,7 @@ function mangle_properties(ast, options) {
if (options.only_cache) {
return cache.props.has(name);
}
if (/^[0-9.]+$/.test(name)) return false;
if (/^-?[0-9]+(\.[0-9]+)?(e[+-][0-9]+)?$/.test(name)) return false;
return true;
}