From 0647d374a3ef72e78d32773ab1e667c902e22e7c Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Wed, 17 Jun 2015 02:09:38 +0100 Subject: [PATCH] add more comments --- src/babel/traversal/path/ancestry.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/babel/traversal/path/ancestry.js b/src/babel/traversal/path/ancestry.js index 3bdac714af..9ced9ddc50 100644 --- a/src/babel/traversal/path/ancestry.js +++ b/src/babel/traversal/path/ancestry.js @@ -39,6 +39,7 @@ export function getEarliestCommonAncestorFrom(paths: Array): NodePath for (var ancestry of (ancestries: Array)) { var path = ancestry[i + 1]; + // first path if (!earliest) { earliest = path; continue; @@ -46,7 +47,7 @@ export function getEarliestCommonAncestorFrom(paths: Array): NodePath // handle containers if (path.listKey && earliest.listKey === path.listKey) { - // we're in the same container so check + // we're in the same container so check if we're earlier if (path.key < earliest.key) { earliest = path; continue; @@ -57,7 +58,7 @@ export function getEarliestCommonAncestorFrom(paths: Array): NodePath var earliestKeyIndex = keys.indexOf(earliest.parentKey); var currentKeyIndex = keys.indexOf(path.parentKey); if (earliestKeyIndex > currentKeyIndex) { - // key appears after + // key appears before so it's earlier earliest = path; } } @@ -117,6 +118,7 @@ export function getDeepestCommonAncestorFrom(paths: Array, filter?: Fu } } + // next iteration may break so store these so they can be returned lastCommonIndex = i; lastCommon = shouldMatch; }