- From: James Browning <notifications@github.com>
- Date: Thu, 08 Oct 2026 03:57:54 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/1509@github.com>
Jamesernator created an issue (whatwg/dom#1509)
### What is the issue with the DOM Standard?
I'm not sure how much flexibility implementations are meant to have regarding emitting different mutation records, but basically the following code has different results in Chrome/Firefox compared to Webkit (tested on Epiphany):
```js
const parent = document.createElement("div");
const fragment = new DocumentFragment();
fragment.append(document.createElement("foo"), document.createElement("bar"));
const observer = new MutationObserver(console.log);
observer.observe(frag, { childList: true });
target.append(frag);
console.log(o.takeRecords());
```
In Chrome/Firefox this prints a single mutation record with both elements in `removedNodes`, but in Webkit this produces two mutation records with `removedNodes` containing a single element in each record.
From what I tell, Webkit's behavior is faithful to the specification as it is a consequence of appending the fragment's children individually to the new document fragment in [convert nodes into a node](https://dom.spec.whatwg.org/#convert-nodes-into-a-node):
```
Let fragment be the result of [creating a document fragment](https://dom.spec.whatwg.org/#create-a-document-fragment) given document.
For each node of nodes: [append](https://dom.spec.whatwg.org/#concept-node-append) node to fragment.
```
It looks like [Ladybird will also have Webkit's behavior](https://github.com/LadybirdBrowser/ladybird/blob/7e8da6e7cf24cd29fddfd87511892ac019ea4cfc/Libraries/LibWeb/DOM/NodeOperations.cpp#L19).
Is this something implementations should align on? Or are implementations expected to have flexibility with regards to the exact batching of their mutation records. (I noticed this because I'm implementing a pure JS implementation of *just* the DOM spec + the HTML parsing methods, and noticed these records didn't match Chrome's).
--
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/1509
You are receiving this because you are subscribed to this thread.
Message ID: <whatwg/dom/issues/1509@github.com>
Received on Thursday, 8 October 2026 10:57:58 UTC