diff options
author | Richard van Velzen <rvanvelzen1@gmail.com> | 2015-01-31 13:22:07 +0100 |
---|---|---|
committer | Richard van Velzen <rvanvelzen1@gmail.com> | 2015-01-31 13:24:44 +0100 |
commit | 605362f89da444e46bae35e7f9384b5cba2eeb80 (patch) | |
tree | 192b5d82ce328f5d7b2ba1dbd43ed2e090843f29 /lib | |
parent | fbbaa42ee55a7f753f7cab9b1a905ccf73cf26d5 (diff) | |
download | tracifyjs-605362f89da444e46bae35e7f9384b5cba2eeb80.tar.gz tracifyjs-605362f89da444e46bae35e7f9384b5cba2eeb80.zip |
Drop all `console` statements properly
Because the base reference can be an member expression as well, we have to dig a bit deeper to find the leftmost base reference.
Fixes #451
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/compress.js b/lib/compress.js index ae20d485..27285984 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1873,11 +1873,16 @@ merge(Compressor.prototype, { } } if (compressor.option("drop_console")) { - if (self.expression instanceof AST_PropAccess && - self.expression.expression instanceof AST_SymbolRef && - self.expression.expression.name == "console" && - self.expression.expression.undeclared()) { - return make_node(AST_Undefined, self).transform(compressor); + if (self.expression instanceof AST_PropAccess) { + var name = self.expression.expression; + while (name.expression) { + name = name.expression; + } + if (name instanceof AST_SymbolRef + && name.name == "console" + && name.undeclared()) { + return make_node(AST_Undefined, self).transform(compressor); + } } } return self.evaluate(compressor)[0]; |