Skip to content

Stdlib: DOMNode replaceChild/insertBefore/removeChild missing — tree mutation fatal (ext/dom/node.c) #14394

Closed

Description

@PurHur

Summary

Classic DOM Level 2 tree mutation on DOMNode — replaceChild(), insertBefore(), and removeChild() — fatals on the VM with undefined method on DOMElement. Zend mutates child order and returns removed/replaced nodes.

Distinct from #14380 append()/prepend() (PHP 8 living-standard helpers); these legacy methods are still required for php-src parity and existing XML tooling.

php-src reference

PHP implementation target

  • ext/dom/VmDom.php + node wrappers (PHP-in-PHP; thin libxml ABI only)

Repro (php-src-strict)

./script/docker-exec.sh -- php test/repro/maintainer_gap_dom_node_tree_mutation.php          # Zend: ok
./script/docker-exec.sh -- php bin/vm.php test/repro/maintainer_gap_dom_node_tree_mutation.php  # VM: fatal replaceChild

Done when

  • replaceChild / insertBefore / removeChild match Zend child order and return values (php-src-strict)
  • Wrong-document and not-a-child errors match php-src
  • test/repro/maintainer_gap_dom_node_tree_mutation.php green on VM
  • PHPUnit guard; VM/JIT/AOT agree when both in scope

Activity

  1. added
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jul 1, 2026
  2. PurHur commented on Jul 2, 2026

    @PurHur
    OwnerAuthor

    claim: cursor-agent-lane-c — batch (issues #14408, #14394)

  3. PurHur commented on Jul 2, 2026

    @PurHur
    OwnerAuthor

    Merged via #15030 — replaceChild/insertBefore/removeChild repro + compliance green on VM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions