[whatwg/dom] replaceChildren contains a step that is incorrect when node is null (#901)

The [replaceChildren method](https://dom.spec.whatwg.org/#dom-parentnode-replacechildren) has a step that says:

> Ensure pre-insertion validity of node into this before null.

But this does not correctly handle the case where the node is null. In that case, this step should be skipped. A misunderstanding about this may have led to [an interoperability bug in WebKit’s implementation of replaceChildren](https://bugs.webkit.org/show_bug.cgi?id=217537).

It seems that there is a similar issue in the [prepend](https://dom.spec.whatwg.org/#dom-parentnode-prepend) and [append](https://dom.spec.whatwg.org/#dom-parentnode-append) methods, where is is not made clear what the methods should do if the result of converting nodes into a node is null. I presume the desired behavior is silently doing nothing, but a careful reading of the current specification seems to imply they should throw an exception during the [ensure pre-insertion validity](https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity) step.

One way to resolve all of these issues might be to revise the [ensure pre-insertion validity](https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity) steps to explicitly do nothing if node is null.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/901

Received on Saturday, 10 October 2020 18:31:30 UTC