From 7afc9503f43b700c8d62a8dcdf07a4b542072a4c Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Tue, 18 Oct 2022 11:18:10 +0200 Subject: [PATCH] Make adoption account for DocumentFragment nodes with hosts Tests: https://github.com/web-platform-tests/wpt/pull/22504. Corresponding HTML PR: https://github.com/whatwg/html/pull/5413. Closes #813 and closes #814. --- dom.bs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/dom.bs b/dom.bs index 7fc68016..5af3f8fc 100644 --- a/dom.bs +++ b/dom.bs @@ -5329,8 +5329,8 @@ method steps are: algorithm is passed node and oldDocument, as indicated in the adopt algorithm. -

To adopt a node into a document, run -these steps: +

To adopt a node into a document, +with an optional forceDocumentFragmentAdoption (default false):

  1. Let oldDocument be node's node document. @@ -5347,6 +5347,16 @@ these steps: shadow-including inclusive descendants:

      +
    1. +

      If forceDocumentFragmentAdoption is false, inclusiveDescendant is a + {{DocumentFragment}} node, inclusiveDescendant is node, and + node's host is non-null, then + continue. + +

      This is only reasonable as long as all adopt callers remove the children + of node. HTML's <{template}> element passes true for + forceDocumentFragmentAdoption. +

    2. Set inclusiveDescendant's node document to document.

    3. If inclusiveDescendant is an element, then set the @@ -5375,6 +5385,12 @@ these steps:

    4. If node is a shadow root, then throw a "{{HierarchyRequestError!!exception}}" {{DOMException}}. +

    5. +

      If node is a {{DocumentFragment}} node and its + host is non-null, then return node. + +

      Unfortunately this does not throw for web compatibility. +

    6. Adopt node into this.

    7. Return node.