mangle: do not mangle reserved class
This commit is contained in:
parent
c46b9f361a
commit
daf099178d
|
|
@ -71,6 +71,9 @@ SymbolDef.prototype = {
|
|||
|| this.orig[0] instanceof AST_SymbolDefun))
|
||||
|| this.orig[0] instanceof AST_SymbolMethod
|
||||
|| (options.keep_classnames
|
||||
&& (this.orig[0] instanceof AST_SymbolClass
|
||||
|| this.orig[0] instanceof AST_SymbolDefClass))
|
||||
|| (options.reserved && options.reserved.indexOf(this.name) >= 0
|
||||
&& (this.orig[0] instanceof AST_SymbolClass
|
||||
|| this.orig[0] instanceof AST_SymbolDefClass));
|
||||
},
|
||||
|
|
|
|||
27
test/mocha/reserved-class.js
Normal file
27
test/mocha/reserved-class.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
var Uglify = require('../../');
|
||||
var assert = require("assert");
|
||||
|
||||
describe("mangle: reserved_class", function () {
|
||||
var input_js = `
|
||||
(function() {
|
||||
class Foo extends HTMLElement {}
|
||||
Foo.reg;
|
||||
class Hello extends HTMLElement {}
|
||||
Hello.reg;
|
||||
})();
|
||||
`;
|
||||
var output_js = '!function(){class e extends HTMLElement{}e.reg;class Hello extends HTMLElement{}Hello.reg}();'
|
||||
|
||||
it("Should test mangle with reserved_class.", function () {
|
||||
var result = Uglify.minify(input_js, {
|
||||
mangle: {
|
||||
reserved: ['Hello'],
|
||||
properties: false,
|
||||
keep_classnames: false,
|
||||
},
|
||||
});
|
||||
assert.strictEqual(result.code, output_js);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user