Re: [whatwg/dom] Proposal: New method to reorder child nodes (#891)

I think that the closest practical solution to this is the shadow dom with the imperative slot api.
```javascript
// Initially <body>abc</body>
const a = document.createTextNode("a")
const b = document.createTextNode("b")
const c = document.createTextNode("c")
document.body.append(a, b, c)

// body is a shadow host with a manually assigned slot
const slot = document.createElement("slot")
document.body
  .attachShadow({
    mode: "open",
    slotAssignment: "manual"
  })
  .append(slot)
// can put child nodes in any order, exclude them, &c.
// even iframes will behave as if nothing happened
slot.assign(c, b, a)
```

<img width="459" alt="Screen Shot 2022-09-25 at 2 42 51 PM" src="https://user-images.githubusercontent.com/20387688/192160014-418388d8-171b-4731-a1a8-2b33d9d07164.png">

Since it's just a slot, there's no fumbling with style sheets or anything either, and it works without custom elements. However, there are restrictions on what elements can be shadow hosts.


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

Message ID: <whatwg/dom/issues/891/1257254789@github.com>

Received on Sunday, 25 September 2022 18:50:24 UTC