fix export and import specifier getIds and add support for computed properties to isReferenced

This commit is contained in:
Sebastian McKenzie
2014-12-16 08:07:18 +11:00
parent fc7fc384c9
commit 01bdb7efdc

View File

@@ -128,8 +128,8 @@ t.isDynamic = function (node) {
};
t.isReferenced = function (node, parent) {
// we're a property key so we aren't referenced
if (t.isProperty(parent) && parent.key === node) return false;
// 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;
// we're a variable declarator id so we aren't referenced
if (t.isVariableDeclarator(parent) && parent.id === node) return false;
@@ -256,8 +256,8 @@ t.getIds = function (node, map, ignoreTypes) {
t.getIds.nodes = {
AssignmentExpression: "left",
ImportSpecifier: "id",
ExportSpecifier: "id",
ImportSpecifier: "name",
ExportSpecifier: "name",
VariableDeclarator: "id",
FunctionDeclaration: "id",
ClassDeclaration: "id",