parent
66cebbf336
commit
9812cba843
10
README.md
10
README.md
|
|
@ -76,7 +76,11 @@ The available options are:
|
|||
not used.
|
||||
-m, --mangle [options] Mangle names/specify mangler options.
|
||||
--mangle-props [options] Mangle properties/specify mangler options:
|
||||
`builtins` Mangle property names that overlaps
|
||||
with standard JavaScript globals.
|
||||
`debug` Add debug prefix and suffix.
|
||||
`domprops` Mangle property names that overlaps
|
||||
with DOM properties.
|
||||
`ignore_quoted` Only mangle unquoted properies.
|
||||
`regex` Only mangle matched property names.
|
||||
-b, --beautify [options] Beautify output/specify output options:
|
||||
|
|
@ -142,12 +146,6 @@ The available options are:
|
|||
specify the name that your module will take
|
||||
when included in, say, a browser.
|
||||
```
|
||||
TODOs:
|
||||
```
|
||||
--reserved-file File containing reserved names
|
||||
--reserve-domprops Make (most?) DOM properties reserved for
|
||||
--mangle-props
|
||||
```
|
||||
|
||||
Specify `--output` (`-o`) to declare the output file. Otherwise the output
|
||||
goes to STDOUT.
|
||||
|
|
|
|||
|
|
@ -77,6 +77,14 @@ if (program.keepFnames) {
|
|||
options.keep_fnames = true;
|
||||
}
|
||||
if (program.mangleProps) {
|
||||
if (program.mangleProps.domprops) {
|
||||
delete program.mangleProps.domprops;
|
||||
} else {
|
||||
if (!Array.isArray(program.mangleProps.reserved)) program.mangleProps.reserved = [];
|
||||
require("../tools/domprops").forEach(function(name) {
|
||||
UglifyJS.push_uniq(program.mangleProps.reserved, name);
|
||||
});
|
||||
}
|
||||
if (typeof options.mangle != "object") options.mangle = {};
|
||||
options.mangle.properties = program.mangleProps;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,16 +43,16 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
function find_builtins() {
|
||||
function find_builtins(reserved) {
|
||||
// NaN will be included due to Number.NaN
|
||||
var a = [
|
||||
[
|
||||
"null",
|
||||
"true",
|
||||
"false",
|
||||
"Infinity",
|
||||
"-Infinity",
|
||||
"undefined",
|
||||
];
|
||||
].forEach(add);
|
||||
[ Object, Array, Function, Number,
|
||||
String, Boolean, Error, Math,
|
||||
Date, RegExp
|
||||
|
|
@ -63,13 +63,13 @@ function find_builtins() {
|
|||
}
|
||||
});
|
||||
function add(name) {
|
||||
push_uniq(a, name);
|
||||
push_uniq(reserved, name);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
function mangle_properties(ast, options) {
|
||||
options = defaults(options, {
|
||||
builtins: false,
|
||||
cache: null,
|
||||
debug: false,
|
||||
ignore_quoted: false,
|
||||
|
|
@ -78,9 +78,8 @@ function mangle_properties(ast, options) {
|
|||
reserved: null,
|
||||
});
|
||||
|
||||
var reserved = options.reserved;
|
||||
if (reserved == null)
|
||||
reserved = find_builtins();
|
||||
var reserved = options.reserved || [];
|
||||
if (!options.builtins) find_builtins(reserved);
|
||||
|
||||
var cache = options.cache;
|
||||
if (cache == null) {
|
||||
|
|
|
|||
11204
tools/domprops.json
11204
tools/domprops.json
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user