diff --git a/lib/6to5/traverse/scope.js b/lib/6to5/traverse/scope.js index cb45f4d2c6..d20b5aba56 100644 --- a/lib/6to5/traverse/scope.js +++ b/lib/6to5/traverse/scope.js @@ -21,15 +21,19 @@ function Scope(block, parent) { this.references = this.getReferences(); } +Scope.add = function (node, references) { + if (!node) return; + _.merge(references, t.getIds(node, true)); +}; + Scope.prototype.getReferences = function () { var block = this.block; if (block._scopeReferences) return block._scopeReferences; - var self = this; var references = block._scopeReferences = {}; var add = function (node) { - self.add(node, references); + Scope.add(node, references); }; // ForStatement - left, init @@ -116,9 +120,8 @@ Scope.prototype.push = function (name, id, init) { } }; -Scope.prototype.add = function (node, references) { - if (!node) return; - _.merge(references || this.references, t.getIds(node, true)); +Scope.prototype.add = function (node) { + Scope.add(node, this.references); }; Scope.prototype.get = function (id) {