From 8dafaf74702bb7e15b6f653d432ff280f5e875ed Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Fri, 27 Mar 2020 20:22:13 +0100 Subject: [PATCH] Make adoption account for DocumentFragment nodes with hosts Tests: ... Corresponding HTML PR: ... Closes #813 and closes #814. --- dom.bs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/dom.bs b/dom.bs index 85b43079..575f8ce7 100644 --- a/dom.bs +++ b/dom.bs @@ -5260,10 +5260,15 @@ when invoked, must run these steps: 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, run these steps:

    +
  1. +

    If forceDocumentFragmentAdoption is not given, then set it false. + +

    This is needed for HTML's <{template}> element. +

  2. Let oldDocument be node's node document.

  3. If node's parent is non-null, then remove @@ -5278,6 +5283,15 @@ 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. +

    2. Set inclusiveDescendant's node document to document.

    3. If inclusiveDescendant is an element, then set the @@ -5307,6 +5321,12 @@ must run 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.