Skip to content

Implement DOMDocumentFragment createDocumentFragment/appendChild (#6317) - #14374

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-6317-dom-document-fragment
Jul 1, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-6317-dom-document-fragment

Conversation

@PurHur

@PurHur PurHur commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Register DOMDocumentFragment and DOMDocument::createDocumentFragment() in PHP-in-PHP ext/dom/.
  • Implement fragment appendChild() and merge fragment children into parent nodes without a wrapper element (php-src ext/dom/php_dom.c).
  • Fix DOMDocument::appendChild() when a document element already exists: append siblings to the document instead of redirecting into the root element.

Verification

./script/docker-exec.sh -- bash -lc 'vendor/bin/phpunit --filter dom_document_fragment'
# OK (2 tests, 2 assertions) — VM + JIT

./script/docker-exec.sh -- bash -lc 'php bin/vm.php -r "var_export(class_exists(\"DOMDocumentFragment\")); echo PHP_EOL;"'
# bool(true)

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/dom_document_fragment.php'
# class ok / instance ok / fragment empty after merge / saveXML shows <root><item/></root>

Closes #6317

Made with Cursor

Add PHP-in-PHP DOM document fragment nodes so batch subtree append merges
children without an extra wrapper element, matching php-src ext/dom behavior.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 2d81d62 into master Jul 1, 2026
@PurHur
PurHur deleted the agent/issue-6317-dom-document-fragment branch July 1, 2026 04:29
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.

Stdlib: DOMDocumentFragment — createDocumentFragment/appendChild missing (ext/dom/php_dom.c, phase 2 #3326)

1 participant