We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent aab9801 commit 595ff9aCopy full SHA for 595ff9a
lib/SymbolTree.js
@@ -207,13 +207,17 @@ class SymbolTree {
207
* @method following
208
* @memberOf module:symbol-tree#
209
* @param {!Object} object
210
- * @param {Object} [treeRoot] If set, `treeRoot` must be an inclusive ancestor
+ * @param {Object} [options]
211
+ * @param {Object} [options.root] If set, `root` must be an inclusive ancestor
212
* of the return value (or else null is returned). This check _assumes_
213
* that `root` is also an inclusive ancestor of the given `node`
- * @param {Boolean} [skipChildren=false] If set, ignore the childen of `object`
214
+ * @param {Boolean} [options.skipChildren=false] If set, ignore the children of `object`
215
* @returns {?Object}
216
*/
- following(object, treeRoot, skipChildren) {
217
+ following(object, options) {
218
+ const treeRoot = options && options.root;
219
+ const skipChildren = options && options.skipChildren;
220
+
221
const first = !skipChildren && this._node(object).first;
222
223
if (first) {
@@ -348,7 +352,7 @@ class SymbolTree {
348
352
if (filter.call(thisArg, object)) {
349
353
array.push(object);
350
354
}
351
- object = this.following(object, root);
355
+ object = this.following(object, {root: root});
356
357
358
return array;
lib/TreeIterator.js
@@ -40,7 +40,7 @@ class TreeIterator {
40
this[NEXT] = tree.preceding(value, {root: root});
41
42
else /*if (iterateFunc === 5)*/ {
43
- this[NEXT] = tree.following(value, root);
+ this[NEXT] = tree.following(value, {root: root});
44
45
46
return {
test/SymbolTree.js
@@ -591,11 +591,11 @@ test('following using a specified root', function(t) {
591
tree.insertLast(aaa, aa);
592
tree.insertAfter(b, a);
593
594
- t.equal(null, tree.following(aaa, aaa));
595
- t.equal(null, tree.following(aaa, aa));
596
- t.equal(null, tree.following(aaa, a));
597
- t.equal(aa , tree.following(a, a));
598
- t.equal(aaa , tree.following(aa, a));
+ t.equal(null, tree.following(aaa, {root: aaa}));
+ t.equal(null, tree.following(aaa, {root: aa}));
+ t.equal(null, tree.following(aaa, {root: a}));
+ t.equal(aa , tree.following(a , {root: a}));
+ t.equal(aaa , tree.following(aa , {root: a}));
599
600
t.end();
601
});
@@ -609,7 +609,7 @@ test('following with skipChildren', function(t) {
609
tree.insertLast(aa, a);
610
611
612
- t.equal(b, tree.following(a, null, true));
+ t.equal(b, tree.following(a, {skipChildren: true}));
613
614
615
0 commit comments