From c50b124d582fbde1e8eac98d4b37060f2c00911b Mon Sep 17 00:00:00 2001 From: Soreine Date: Tue, 1 Nov 2016 14:33:14 +0100 Subject: [PATCH] Unmemoize getFurthest and make it use getAncestors --- src/models/node.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/models/node.js b/src/models/node.js index a44262566..ceead7cf0 100644 --- a/src/models/node.js +++ b/src/models/node.js @@ -524,14 +524,13 @@ const Node = { */ getFurthest(key, iterator) { - let node = this.assertDescendant(key) - let furthest = null - - while (node = this.getClosest(node, iterator)) { - furthest = node + let ancestors = this.getAncestors(key) + if (!ancestors) { + throw new Error(`Could not find a descendant node with key "${key}".`) } - return furthest + // Exclude this node itself + return ancestors.rest().find(iterator) }, /** @@ -1336,7 +1335,6 @@ memoize(Node, [ 'getDescendantDecorators', 'getFirstText', 'getFragmentAtRange', - 'getFurthest', 'getFurthestBlock', 'getFurthestInline', 'getHighestChild',