From bf8f80faf7e4eddcc67754613aad84ac76bba068 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Wed, 11 Feb 2015 20:14:41 +1100 Subject: [PATCH] add general support for declarations to Scope::rename - closes #751 --- lib/6to5/traversal/scope.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/6to5/traversal/scope.js b/lib/6to5/traversal/scope.js index 47df9504f7..55f4ebca48 100644 --- a/lib/6to5/traversal/scope.js +++ b/lib/6to5/traversal/scope.js @@ -159,6 +159,11 @@ Scope.prototype.rename = function (oldName, newName) { enter: function (node, parent, scope) { if (t.isReferencedIdentifier(node, parent) && node.name === oldName) { node.name = newName; + } else if (t.isDeclaration(node)) { + var ids = t.getBindingIdentifiers(node); + for (var name in ids) { + if (name === oldName) ids[name].name = newName; + } } else if (t.isScope(node, parent)) { if (!scope.bindingIdentifierEquals(oldName, binding)) { this.skip();