Repository navigation
Conversation
hohphu8
force-pushed
the
fix-dom-adoptnode-template-fragments
branch
from
November 26, 2026 19:42
e0f913a to
d9468c7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
Dom\Document::adoptNode()moves an HTML<template>element (directly, wrapped in another element, or nested inside another<template>) to a different document,php_dom_adopt_node()updates the node tree's document reference but leaves the template's fragment in the source document'sprivate_data->template_fragments. The template contents are then missing fromsaveHtml()andinnerHTML, and get freed when the source document is destroyed.This adds
php_dom_detach_templated_content()inext/dom/private_data.{c,h}and updatesphp_dom_adopt_node()(ext/dom/document.c) to recursively detach and transfer template fragments in the adopted subtree to the destination document'sprivate_data(includingxmlSetTreeDoc, namespace reconciliation,< 2.13libxml2 dictionary fixup, document ref transfer, anddom_add_element_ns_hook).Adds
ext/dom/tests/modern/spec/Document_adoptNode_template.phptcovering direct, wrapped, and nested<template>elements both before and afterunset($src). VerifiedFAIL -> PASSonPHP-8.4(Debug + ZTS) withext/dom/tests/modern/passing.Found via LLM-assisted source inspection and manually reproduced