Re: [whatwg/dom] Add convenient, ergonomic, performant API for sorting siblings (#586)

It does not address this case (and variations thereof):

```JS
const GimmeAKeyedList() {
  return someArray.map(x => <div key={x}>x</div>)
}

render(root, <div>
  <hr />
  <GimmeAKeyedList />
  <hr />
</div>
)
```

Suppose that `GimmeAKeyedList` can redraw on its own (as it would in a finely grained framework, or in React with `useState`) in order to tap into the proposed API, it has to

1) determine in what order it wants to render its own values
2) scour the parent north and south to gather the list of elements that precede and follow its own.
3) assemble 1 and 2 into a single list
4) pass it to the browser which has to consider more nodes than needed.

In order to handle that case efficiently, frameworks need an API that has the conceptual shape I suggested. I could also be
```ts
parent.replaceChildren(nodes: Array<Nodes|null>, options?: {previousSibling?,nextSibling?})
```

Which would make it more ergonomic when you want to replace/reorder all the children of an element.

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

Message ID: <whatwg/dom/issues/586/1424781864@github.com>

Received on Thursday, 9 February 2023 20:36:05 UTC