From 1b137ba13ac66680978129b0a449a8de4500e594 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Fri, 10 Jan 2020 16:04:14 +0100 Subject: [PATCH 1/2] Revert "Run adopt as part of insert" This reverts commit c825ceaf3cb77943f487f85533d8be79bccd2fe3. See #813 and #814 for context. --- dom.bs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/dom.bs b/dom.bs index 5162a42a..7fc68016 100644 --- a/dom.bs +++ b/dom.bs @@ -2509,6 +2509,8 @@ of a node into a parent before a child, run the
  • If referenceChild is node, then set referenceChild to node's next sibling. +

  • Adopt node into parent's node document. +

  • Insert node into parent before referenceChild.

  • Return node. @@ -2574,8 +2576,6 @@ before a child, with an optional suppress observers flag, run

    For each node in nodes, in tree order:

      -
    1. Adopt node into parent's node document. -

    2. If child is null, then append node to parent's children. @@ -2689,6 +2689,8 @@ within a parent, run these steps:

    3. Let previousSibling be child's previous sibling. +

    4. Adopt node into parent's node document. +

    5. Let removedNodes be the empty set.

    6. @@ -2721,6 +2723,9 @@ within a parent, run these steps: within a parent, run these steps:
        +
      1. If node is non-null, then adopt node into parent's + node document. +

      2. Let removedNodes be parent's children.

      3. Let addedNodes be the empty set. @@ -5370,9 +5375,6 @@ these steps:

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

      5. If node is a {{DocumentFragment}} node whose - host is non-null, then return. -

      6. Adopt node into this.

      7. Return node. From 7afc9503f43b700c8d62a8dcdf07a4b542072a4c Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Tue, 18 Oct 2022 11:18:10 +0200 Subject: [PATCH 2/2] 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.