Skip to content

Add regression tests for the child combinator matching the root - #112

Merged
jakejackson1 merged 1 commit into
mainfrom
fix/issue-74
Oct 26, 2026
Merged

jakejackson1 merged 1 commit into
mainfrom
fix/issue-74

Conversation

@gravitypdf-bot

Copy link
Copy Markdown
Contributor

Adds regression coverage for #74, which was fixed in #50.

When the right-hand side of X > * matched the root element, combineDirectDescendant() passed the document to matchesSimpleSelector(), which threw a TypeError:

qp('<?xml version="1.0"?><root><wrap><a/><b/></wrap></root>', 'wrap > *'); // TypeError before #50

#50 added a guard for this, but the suite still passed with the guard removed.

tests/Issues/Issue74Test.php asserts the matched tag names for:

  • wrap > *, root > * and * > * through qp(), both as the constructor selector and through find()
  • ul > * through htmlqp() and html5qp()
  • * *, * + * and * ~ *, whose right-hand sides also match the root

With the guard removed, the child combinator tests fail with the TypeError from the issue. The descendant and sibling cases protect the non-element skips in those combinators' own loops. This is a test-only change with no behaviour change, so there's no CHANGELOG entry.

Refs #74.

🤖 Generated with Claude Code

…e root

X > * also matches the root element, whose parent is the document. The
guard in combineDirectDescendant() added in #50 fixed the TypeError this
caused, but no test failed when it was removed. Cover the descendant,
adjacent and general sibling combinators the same way.

Refs #74

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.75%. Comparing base (6ae6acf) to head (d726f7b).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #112      +/-   ##
============================================
+ Coverage     90.69%   90.75%   +0.06%     
  Complexity     1424     1424              
============================================
  Files            25       25              
  Lines          3170     3170              
============================================
+ Hits           2875     2877       +2     
+ Misses          295      293       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jakejackson1 jakejackson1 added the bug Something isn't working label Oct 26, 2026
@jakejackson1
jakejackson1 merged commit ab4c6d9 into main Oct 26, 2026
14 checks passed
@jakejackson1
jakejackson1 deleted the fix/issue-74 branch October 26, 2026 00:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants