uglify-js
Advanced tools
Comparing version 2.4.5 to 2.4.6
@@ -501,8 +501,2 @@ /*********************************************************************** | ||
// XXX: this is wrong according to ECMA-262 (12.4). the catch block | ||
// should introduce another scope, as the argname should be visible | ||
// only inside the catch block. However, doing it this way because of | ||
// IE which simply introduces the name in the surrounding scope. If | ||
// we ever want to fix this then AST_Catch should inherit from | ||
// AST_Scope. | ||
var AST_Catch = DEFNODE("Catch", "argname", { | ||
@@ -519,3 +513,3 @@ $documentation: "A `catch` node; only makes sense as part of a `try` statement", | ||
} | ||
}, AST_Block); | ||
}, AST_Scope); | ||
@@ -522,0 +516,0 @@ var AST_Finally = DEFNODE("Finally", null, { |
@@ -74,9 +74,6 @@ /*********************************************************************** | ||
AST_Toplevel.DEFMETHOD("figure_out_scope", function(){ | ||
// This does what ast_add_scope did in UglifyJS v1. | ||
// | ||
// Part of it could be done at parse time, but it would complicate | ||
// the parser (and it's already kinda complex). It's also worth | ||
// having it separated because we might need to call it multiple | ||
// times on the same tree. | ||
AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){ | ||
options = defaults(options, { | ||
screw_ie8: false | ||
}); | ||
@@ -86,2 +83,3 @@ // pass 1: setup scope chaining and handle definitions | ||
var scope = self.parent_scope = null; | ||
var defun = null; | ||
var nesting = 0; | ||
@@ -92,7 +90,10 @@ var tw = new TreeWalker(function(node, descend){ | ||
var save_scope = node.parent_scope = scope; | ||
++nesting; | ||
var save_defun = defun; | ||
if (!(node instanceof AST_Catch)) { | ||
defun = node; | ||
} | ||
scope = node; | ||
descend(); | ||
++nesting; descend(); --nesting; | ||
scope = save_scope; | ||
--nesting; | ||
defun = save_defun; | ||
return true; // don't descend again in TreeWalker | ||
@@ -114,3 +115,3 @@ } | ||
if (node instanceof AST_SymbolLambda) { | ||
scope.def_function(node); | ||
defun.def_function(node); | ||
} | ||
@@ -123,7 +124,7 @@ else if (node instanceof AST_SymbolDefun) { | ||
// later. | ||
(node.scope = scope.parent_scope).def_function(node); | ||
(node.scope = defun.parent_scope).def_function(node); | ||
} | ||
else if (node instanceof AST_SymbolVar | ||
|| node instanceof AST_SymbolConst) { | ||
var def = scope.def_variable(node); | ||
var def = defun.def_variable(node); | ||
def.constant = node instanceof AST_SymbolConst; | ||
@@ -133,9 +134,4 @@ def.init = tw.parent().value; | ||
else if (node instanceof AST_SymbolCatch) { | ||
// XXX: this is wrong according to ECMA-262 (12.4). the | ||
// `catch` argument name should be visible only inside the | ||
// catch block. For a quick fix AST_Catch should inherit | ||
// from AST_Scope. Keeping it this way because of IE, | ||
// which doesn't obey the standard. (it introduces the | ||
// identifier in the enclosing scope) | ||
scope.def_variable(node); | ||
(options.screw_ie8 ? scope : defun) | ||
.def_variable(node); | ||
} | ||
@@ -142,0 +138,0 @@ }); |
@@ -6,3 +6,3 @@ { | ||
"main": "tools/node.js", | ||
"version": "2.4.5", | ||
"version": "2.4.6", | ||
"engines": { "node" : ">=0.4.0" }, | ||
@@ -9,0 +9,0 @@ "maintainers": [{ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
360138
8657