Quality: Fix Collection.find() to include matching root nodes when searching descendants#698
Conversation
… 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>
|
@andoan16 is attempting to deploy a commit to the Meta Open Source Team on Vercel. A member of the Team first needs to authorize it. |
|
|
Hi @andoan16! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
✨ Code Quality
Problem
When
find()is called on a collection, it currently only searches descendants of each path usingpath.find(). This means if the collection already contains nodes matching the search criteria, they won't be included in the results becausepath.find()starts traversal from children, not the node itself.Severity:
highFile:
src/collections/Node.jsSolution
In the
findmethod ofsrc/collections/Node.js, modify the traversal to also check if the current node matches. Here's the implementation:Changes
src/collections/Node.js(modified)Testing
🤖 About this PR
This pull request was generated by ContribAI, an AI agent
that helps improve open source projects. The change was:
If you have questions or feedback about this PR, please comment below.
We appreciate your time reviewing this contribution!
Closes #477