add allowPartial option to t.buildMatchMemberExpression, fix t.isReferenced on Property nodes - fixes #656

This commit is contained in:
Sebastian McKenzie
2015-02-02 10:44:56 +11:00
parent fb360039ce
commit 18b836c16a

View File

@@ -257,8 +257,9 @@ t.isReferenced = function (node, parent) {
}
// yes: { [NODE]: "" }
if (t.isProperty(parent)) {
return parent.key === node && parent.computed;
// no: { NODE: "" }
if (t.isProperty(parent) && parent.key === node) {
return parent.computed;
}
// no: var NODE = init;
@@ -407,10 +408,11 @@ t.ensureBlock = function (node, key) {
* parsed nodes of `React.createClass` and `React["createClass"]`.
*
* @param {String} match Dot delimetered string
* @param {Boolean} [allowPartial] Allow a partial match
* @returns {Function}
*/
t.buildMatchMemberExpression = function (match) {
t.buildMatchMemberExpression = function (match, allowPartial) {
var parts = match.split(".");
return function (member) {
@@ -445,7 +447,11 @@ t.buildMatchMemberExpression = function (match) {
// too many parts
if (++i > parts.length) {
return false;
if (partial) {
return true;
} else {
return false;
}
}
}