Repository navigation
🐛 fix(css): bound child-led :has() walks - #2271
Merged
gaborbernat merged 1 commit intoNov 16, 2026
Merged
Conversation
A :has() argument with several compounds and a child or sibling lead walked the whole subtree of every anchor, although its subject sits at most as many levels below the anchor as the argument has compounds. On a deep tree the total work grew with the square of the depth. The walk now stops at that level, so the cost follows the levels the argument names. Fixes tox-dev#2262
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Matching a
:has()argument with several compounds and a child or sibling lead took time that grew with the square of the nesting depth on deep trees. Each candidate anchor walked its whole subtree, although such an argument can reach only as many levels below the anchor as it has compounds. Matching now stops at that depth, so the cost follows the elements those levels reach. Fixes #2262.The walk ignored the argument's depth
The old walk was
sel_has_subtree. It visited every descendant of the anchor for each candidate, even though a child or sibling chain cannot place its subject deeper than the number of its compounds. Descendant arguments already reuse answers on deep trees, so only this form was left unbounded.Such an argument now takes
sel_has_levels, which recurses into a child only while a level of the argument remains. The unbounded walk stays for arguments with a descendant combinator.Behavior changes
Match results do not change. Only the time spent on child- or sibling-led multi-compound
:has()arguments on deep trees changes.Reported by Anthropic OSS Scanner: ANT-2026-IBDOALZF.