Skip to content

perf(queries): Index implicit role rules by tag - #1391

Open
scttcper wants to merge 2 commits into
testing-library:mainfrom
scttcper:scttcper/implicit-role-index
Open

scttcper wants to merge 2 commits into
testing-library:mainfrom
scttcper:scttcper/implicit-role-index

Conversation

@scttcper

Copy link
Copy Markdown

Only check implicit-role selectors for the element's tag. Keep the existing selector matching and specificity order.

Named-button query on a 501-element fixture, median of nine paired batches:

Environment Before After Reduction
jsdom 20.0.0 24.740 ms 22.623 ms 8.6%
jsdom 30.1.0 5.332 ms 2.015 ms 62.2%
Happy DOM 20.14.5 0.543 ms 0.302 ms 44.4%
Chrome 153 0.308 ms 0.188 ms 39.1%
Firefox 142 0.817 ms 0.358 ms 56.1%
WebKit 26 0.404 ms 0.191 ms 52.7%

matches() calls drop from 5,300 to 1,200 per query. These are synthetic query timings, not whole-suite gains. Textbox cases benefit less, with regressions of 3.3% in Happy DOM and 1.2% in WebKit.

Full evidence and runner: 30 benchmark cases, 35,320 behavior comparisons with no differences. Node stayed at 24.14, below jsdom 30.1's declared 24.15 minimum.

Avoid testing selectors for unrelated tags when resolving implicit roles. Keep existing selector matching and rule priority within each tag.

Co-Authored-By: Codex <noreply@openai.com>
@codesandbox-ci

codesandbox-ci Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 85d321d:

Sandbox Source
react-testing-library-examples Configuration

@scttcper
scttcper marked this pull request as ready for review September 17, 2026 06:46
Co-Authored-By: Codex <noreply@openai.com>

This branch has not been deployed

No deployments
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.

1 participant