- From: Andrea Giammarchi <notifications@github.com>
- Date: Tue, 07 Feb 2023 01:39:41 -0800
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Tuesday, 7 February 2023 09:39:54 UTC
> And there is also the [replaceChildren](https://developer.mozilla.org/en-US/docs/Web/API/Element/replaceChildren) API... As that name suggests, `replaceChildren` does, in fact, **replace** children, it doesn't re-order children. With this argument, we don't need any sorting API neither: ```js parent.replaceChildren( [...parent.children].sort( (a, b) => ( parseFloat(a.dataset.order) - parseFloat(b.dataset.order) ) ) ); ``` If the sorting is smarter at *not* removing children that don't need to be moved (less mutations on the tree) then it is a missed opportunity to confine that ability to same list length and same nodes only and via attributes, that is why I've raised my suggestion we could do a little more and solve diffing forever on the DOM. -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/issues/586#issuecomment-1420472637 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/dom/issues/586/1420472637@github.com>
Received on Tuesday, 7 February 2023 09:39:54 UTC