Skip to content

Return empty document fragment from appendChild - #478

Merged
g105b merged 1 commit into
phpgt:masterfrom
oiahoon:fix/return-empty-document-fragment
Jul 12, 2026
Merged

Return empty document fragment from appendChild#478
g105b merged 1 commit into
phpgt:masterfrom
oiahoon:fix/return-empty-document-fragment

Conversation

@oiahoon

@oiahoon oiahoon commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • return an empty DocumentFragment from appendChild() instead of propagating the native false result
  • add a regression test that verifies object identity and confirms the parent remains unchanged

Why

PHP's native DOMNode::appendChild() returns false for an empty document fragment. The wrapper's strict return type turns that value into a TypeError, while the DOM API is expected to return the appended fragment.

Testing

  • composer test (960 tests, 3829 assertions; PHPStan, PHPCS, and PHPMD passed)
  • composer validate --strict --no-check-publish
  • focused NodeTest and DocumentFragmentTest suite (65 tests, 95 assertions)
  • manual empty and non-empty fragment checks

Closes #458

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@g105b g105b left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks perfect.

@g105b
g105b merged commit 7374f67 into phpgt:master Jul 12, 2026
31 checks passed
@g105b

g105b commented Jul 12, 2026

Copy link
Copy Markdown
Member

Thank you @oiahoon !

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.

Bug: appending a DocumentFragment returns false if fragment is empty

2 participants