diff options
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js index aedd78fd..9d5dac17 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -742,6 +742,13 @@ function Compressor(options, false_by_default) { /* -----[ node squeezers ]----- */ + SQUEEZE(AST_Directive, function(self, compressor){ + if (self.hoisted || self.scope.has_directive(self.value) !== self.scope) { + return new AST_EmptyStatement(self); + } + return self; + }); + SQUEEZE(AST_Debugger, function(self, compressor){ if (compressor.option("drop_debugger")) return new AST_EmptyStatement(self); @@ -796,6 +803,10 @@ function Compressor(options, false_by_default) { var vars = {}, vars_found = 0, vardecl = []; var tw = new TreeWalker(function(node){ if (node !== self) { + if (node instanceof AST_Directive && (hoist_funs || hoist_vars) && !node.hoisted) { + hoisted.unshift(node.clone()); + node.hoisted = true; + } if (node instanceof AST_Defun && hoist_funs && !node.hoisted) { hoisted.push(node.clone()); node.hoisted = true; |