refactor: switch ancestory/descendant logic [skip ci]

- Ref https://github.com/babel/babel/pull/4836#discussion_r88118790 @jridgewell
This commit is contained in:
Henry Zhu 2016-11-15 16:40:47 -05:00
parent 55a47a8819
commit 4462d59acd

View File

@ -179,14 +179,14 @@ export function getAncestry() {
* A helper to find if `this` path is an ancestor of @param maybeDescendant
*/
export function isAncestor(maybeDescendant) {
return !!maybeDescendant.findParent((parent) => parent === this);
return maybeDescendant.isDescendant(this);
}
/**
* A helper to find if `this` path is a descendant of @param maybeAncestor
*/
export function isDescendant(maybeAncestor) {
return maybeAncestor.isAncestor(this);
return !!this.findParent((parent) => parent === maybeAncestor);
}
export function inType() {