Skip to content

Resolve createElement() prefixes against the first match, not the root - #102

Merged
gravitypdf-bot merged 1 commit into
mainfrom
fix/issue-94
Oct 25, 2026
Merged

gravitypdf-bot merged 1 commit into
mainfrom
fix/issue-94

Conversation

@gravitypdf-bot

Copy link
Copy Markdown
Contributor

Fixes #94

QPXML::createElement() resolved a name's prefix with ownerDocument->lookupNamespaceURI(), so only prefixes declared on the document element worked; one declared lower down threw "Undefined namespace for: y:item". It now resolves the prefix against the first matched element, where root-declared prefixes are in scope too.

The foreach that returned on its first pass is replaced with get(0) and an early return for an empty match set. Callers see the same behaviour as before. The docblock now says the method works on the first match.

Tests:

  • a prefix declared below the root, and one declared on the root;
  • an out-of-scope prefix still throws;
  • only the first match is used;
  • an empty match set returns an empty DOMQuery.

The below-root and first-match tests fail on main.

🤖 Generated with Claude Code

@gravitypdf-bot gravitypdf-bot changed the title QPXML::createElement() only resolves prefixes declared on the document element Resolve createElement() prefixes against the first match, not the root Oct 25, 2026
@codecov

codecov Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.38%. Comparing base (86f107c) to head (b40b4c3).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/Extension/QPXML.php 90.90% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #102      +/-   ##
============================================
+ Coverage     90.32%   90.38%   +0.05%     
  Complexity     1430     1430              
============================================
  Files            25       25              
  Lines          3185     3181       -4     
============================================
- Hits           2877     2875       -2     
+ Misses          308      306       -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 25, 2026
QPXML::createElement() looked an element name's prefix up on the owner
document, which only sees declarations on the document element, so a
prefix declared on the matched element or an ancestor below the root
threw "Undefined namespace". Look it up on the element instead; root
declarations are in scope there too.

The foreach returned on its first pass, so only the first match was ever
used. Use get(0) so the code says so.

Fixes #94

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gravitypdf-bot
gravitypdf-bot merged commit f4fc544 into main Oct 25, 2026
13 checks passed
@gravitypdf-bot
gravitypdf-bot deleted the fix/issue-94 branch October 25, 2026 23:38
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.

QPXML::createElement() only resolves prefixes declared on the document element

2 participants