diff --git a/lib/6to5/types/index.js b/lib/6to5/types/index.js index e1f0b9ec90..4ba4b9fc6b 100644 --- a/lib/6to5/types/index.js +++ b/lib/6to5/types/index.js @@ -355,16 +355,24 @@ t.getIds = function (node, map, ignoreTypes) { if (!id) continue; if (_.contains(ignoreTypes, id.type)) continue; - var nodeKey = t.getIds.nodes[id.type]; + var nodeKeys = t.getIds.nodes[id.type]; var arrKeys = t.getIds.arrays[id.type]; + var i, key; + if (t.isIdentifier(id)) { ids[id.name] = id; - } else if (nodeKey) { - if (id[nodeKey]) search.push(id[nodeKey]); + } else if (nodeKeys) { + for (i in nodeKeys) { + key = nodeKeys[i]; + if (id[key]) { + search.push(id[key]); + break; + } + } } else if (arrKeys) { - for (var i in arrKeys) { - var key = arrKeys[i]; + for (i in arrKeys) { + key = arrKeys[i]; search = search.concat(id[key] || []); } } @@ -375,15 +383,15 @@ t.getIds = function (node, map, ignoreTypes) { }; t.getIds.nodes = { - AssignmentExpression: "left", - ImportSpecifier: "name", - ExportSpecifier: "name", - VariableDeclarator: "id", - FunctionDeclaration: "id", - ClassDeclaration: "id", - MemeberExpression: "object", - SpreadElement: "argument", - Property: "value" + AssignmentExpression: ["left"], + ImportSpecifier: ["name", "id"], + ExportSpecifier: ["name", "id"], + VariableDeclarator: ["id"], + FunctionDeclaration: ["id"], + ClassDeclaration: ["id"], + MemeberExpression: ["object"], + SpreadElement: ["argument"], + Property: ["value"] }; t.getIds.arrays = {