- From: Stef Busking <notifications@github.com>
- Date: Fri, 14 Jan 2022 06:06:40 -0800
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Friday, 14 January 2022 14:06:52 UTC
Given a `document` that contains an element, and the following code: ``` const fragment = document.createDocumentFragment(); const element = fragment.appendChild(document.createElement('element')); document.replaceChildren(fragment); ``` Expected result: `document` now only contains `element` Actual result: HierarchyRequestError This is caused by replaceChildren calling "ensure pre-insertion validity without taking into consideration that the existing children of the document will be removed. This then fails on the following rule: > Otherwise, if node (the fragment) has one element child and either parent (the document) has an element child, child is a doctype, or child is non-null and a doctype is following child. Perhaps an argument should be added to make this algorithm ignore pre-existing children when called from replaceChild, or perhaps replaceChildren should use a modified copy of these steps, as was done in replaceChild? -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/issues/1045 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/dom/issues/1045@github.com>
Received on Friday, 14 January 2022 14:06:52 UTC