Compare commits

...

3 Commits

Author SHA1 Message Date
Sebastian McKenzie
4744719040 v2.12.2 2015-01-14 18:48:29 +11:00
Sebastian McKenzie
a3b814a897 fix default parameters closure scope 2015-01-14 18:46:36 +11:00
Sebastian McKenzie
f5f17f0ccb ignore function params, rest and catch clauses - webpack/webpack#688 2015-01-14 18:39:07 +11:00
4 changed files with 18 additions and 2 deletions

View File

@@ -11,6 +11,11 @@
_Note: Gaps between patch versions are faulty/broken releases._
## 2.12.2
* **Internal**
* Exclude nodes in function parameters and catch clauses from `isReferenced` check.
## 2.12.1
* **Internal**

View File

@@ -45,7 +45,7 @@ exports.Function = function (node, parent, file, scope) {
}
// we're accessing a variable that's already defined within this function
var has = scope.get(param.name);
var has = scope.get(param.name, true);
if (has && node.params.indexOf(has) < 0) {
iife = true;
}

View File

@@ -193,6 +193,17 @@ t.isReferenced = function (node, parent) {
// we're a property key and we aren't computed so we aren't referenced
if (t.isProperty(parent) && parent.key === node && !parent.computed) return false;
if (t.isFunction(parent)) {
// we're a function param
if (_.contains(parent.params, node)) return false;
// we're a rest parameter
if (_.contains(parent.params, node)) return false;
}
// we're a catch clause param
if (t.isCatchClause(parent) && parent.param === node) return false;
// we're a variable declarator id so we aren't referenced
if (t.isVariableDeclarator(parent) && parent.id === node) return false;

View File

@@ -1,7 +1,7 @@
{
"name": "6to5",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "2.12.1",
"version": "2.12.2",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://github.com/6to5/6to5",
"repository": {