Repository navigation
Fix mixed own and descendant text matching - #319
Merged
facelessuser merged 2 commits intoOct 19, 2026
Merged
Conversation
facelessuser
requested changes
Oct 18, 2026
Owner
|
@gir-bot lgtm |
facelessuser
approved these changes
Oct 19, 2026
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.
Combining
:-soup-contains()and:-soup-contains-own()in one compound selector reuses the first condition's text for both scopes. For<div>own text<span>child text</span></div>, both selectors below should match, but neither does:The shared value can also produce false positives:
:-soup-contains("child text"):-soup-contains-own("c")matches even thoughconly occurs in a descendant.Cache descendant text and direct text nodes separately, computing each only when needed. Add regressions for both orders, alternating conditions, alternative search terms, text-node boundaries, empty patterns, and nested selectors. The regressions use all three HTML parsers with caching enabled and disabled.
Validation on Windows / Python 3.12.8: full suite 419 passed, 12 subtests passed, 100% statement coverage; Ruff and mypy pass. The new regressions expose 10 failing subcases before the fix. An independent Beautiful Soup text oracle passes 2,704 comparisons across four parsers and detects a mismatch with the original method.