Skip to content

Test the adoption agency when script reparents nodes during parsing#61398

Open
annevk wants to merge 2 commits into
masterfrom
adoption-agency-reparenting
Open

Test the adoption agency when script reparents nodes during parsing#61398
annevk wants to merge 2 commits into
masterfrom
adoption-agency-reparenting

Conversation

@annevk

@annevk annevk commented Jul 19, 2026

Copy link
Copy Markdown
Member

The adoption agency algorithm moves existing nodes (the furthest block and its ancestors up to the common ancestor), assuming the DOM tree still matches the stack of open elements. An inline <script> that runs before the misnested end tag can reparent those nodes first — detaching them, moving them into another Document, or nesting them so that a subsequent move would create a cycle.

adoption-agency-reparenting.html covers the well-formed cases (detach, adopt into another Document, foster-parented common ancestor); these are interoperable across engines. The cycle-inducing cases are split into separate files (adoption-agency-reparenting-cycle.html and -inner-loop-cycle.html) so a crash in one does not hide the others; they currently crash Chromium.

The adoption agency algorithm moves existing nodes (the furthest block and its
ancestors up to the common ancestor), assuming the DOM tree still matches the
stack of open elements. An inline <script> that runs before the misnested end
tag can reparent those nodes first — detaching them, moving them into another
Document, or nesting them so that a subsequent move would create a cycle.

adoption-agency-reparenting.html covers the well-formed cases (detach, adopt into
another Document, foster-parented common ancestor); these are interoperable
across engines. The cycle-inducing cases are split into separate files
(adoption-agency-reparenting-cycle.html and -inner-loop-cycle.html) so a crash in
one does not hide the others.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants