Skip to content

Stdlib: DOMNode::replaceChild accept Text/Comment children (#21976) - #22074

Merged
PurHur merged 1 commit into
masterfrom
agent/ext-dom-21976-replacechild-text
Jul 22, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/ext-dom-21976-replacechild-text

Conversation

@PurHur

@PurHur PurHur commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fix DOMNode::replaceChild() rejecting non-Element children (createTextNode → Hierarchy request error) while removeChild+appendChild worked.
  • Align with php-src ext/dom/node.c dom_node_replace_child: allow tree-mutation children (Text/CDATA/Comment/PI/EntityRef/Element); expand DocumentFragment in place; update documentElement only when replacing with/away from an Element.
  • Compliance + repro under test/compliance/cases/dom/ and test/repro/.

Closes #21976

php-src reference

  • ext/dom/node.c — dom_node_replace_child / hierarchy checks

PHP implementation

  • ext/dom/VmDom.php — replaceChild()

Test plan

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/issue_21976_dom_replacechild_text.php'
# before=abcdef / after=ZZ / workaround=YY / attr DOMException

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/jit.php test/repro/issue_21976_dom_replacechild_text.php'
# same

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter dom_node_replacechild_text'
# VM+JIT compliance pass

Pre-claim gates (master): inventory OK 6335/6335; north-star5-fast FAIL gen-0 mismatch #8713 (pre-existing).

Made with Cursor

replaceChild incorrectly required Element newChild, so createTextNode
replacements threw Hierarchy request error while remove+append worked.
Align with php-src tree-mutation child kinds and documentElement updates.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 0ce9c5a into master Jul 22, 2026
@PurHur
PurHur deleted the agent/ext-dom-21976-replacechild-text branch July 22, 2026 06:34
PurHur added a commit that referenced this pull request Jul 22, 2026
…) (#22075)

Emergency stamp: master lib/ext moved after the last fingerprint stamp,
re-breaking north-star5-fast 4f-m (manifest 8b4e4f06… vs live d22247bd…).
Honest blob rebuild still deferred; spine sidecar SHA already matches.

Co-authored-by: PurHur <PurHur@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
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.

Regression: DOMNode::replaceChild(createTextNode, textChild) throws Hierarchy request error (re-#21182/#14394, ext/dom/node.c)

1 participant