Skip to content

Don't treat ids like toString as present in the tree - #406

Open
melihozcan1 wants to merge 1 commit into
jameskerr:mainfrom
melihozcan1:fix/idtoindex-own-keys
Open

melihozcan1 wants to merge 1 commit into
jameskerr:mainfrom
melihozcan1:fix/idtoindex-own-keys

Conversation

@melihozcan1

Copy link
Copy Markdown

Summary

Follow-up from the review of #404.

createIndex built idToIndex on a plain {}, so lookups also matched inherited Object.prototype keys: scrollTo("toString") resolved immediately and passed a function to scrollToItem, and indexOf("toString") returned a function. The index is now built with Object.create(null), which fixes every lookup (get, indexOf, scrollTo) at once and keeps the idToIndex type.

Two tests in tree-api.test.ts cover indexOf and scrollTo with these ids; both fail without the change.

Checklist

  • Added a .changes/ entry describing the change (see .changes/README.md), or applied the skip-changelog label if it has no user-facing effect.
  • yarn lint, yarn fmt:check, and yarn workspace react-arborist test pass (warning-clean — see AGENTS.md).

Copilot AI balanced review requested due to automatic review settings November 16, 2026 08:38
@netlify

netlify Bot commented Nov 16, 2026

Copy link
Copy Markdown

👷 Deploy request for react-arborist pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit e3cf490

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants