From 857637d9d8273eafb417ffc33a183622e2ec3d94 Mon Sep 17 00:00:00 2001 From: andoan16 <33853760+andoan16@users.noreply.github.com> Date: Sat, 11 Apr 2026 09:12:58 +0700 Subject: [PATCH] refactor(collections): fix collection.find() to include matching root nodes when searching descendants When `find()` is called on a collection, it currently only searches descendants of each path using `path.find()`. This means if the collection already contains nodes matching the search criteria, they won't be included in the results because `path.find()` starts traversal from children, not the node itself. Affected files: Node.js Signed-off-by: andoan16 <33853760+andoan16@users.noreply.github.com> --- src/collections/Node.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/collections/Node.js b/src/collections/Node.js index a1a909dd..ede29edf 100644 --- a/src/collections/Node.js +++ b/src/collections/Node.js @@ -45,6 +45,9 @@ const traversalMethods = { const self = this; visitor[visitorMethodName] = function(path) { if (self.__paths[i] === path) { + if (type.check(path.value) && (!filter || matchNode(path.value, filter))) { + paths.push(path); + } this.traverse(path); } else { return visit.call(this, path);