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

> preserves its rendering or something

The state you're interested is a nested [browsing context](https://html.spec.whatwg.org/multipage/browsers.html#concept-document-bc). These contexts are created corresponding to each "connectedness lifetime" (from insertion to removal) of the element, but they are not the element itself. Disconnecting the element is somewhat like closing a tab.

Right now, if you have iframes [ A, B ] as siblings in that order, there is (to my knowledge) no way to get them in the order [ B, A ] without destroying one of those browsing contexts. This is a spot where a reordering primitive would potentially help.

If I understand correctly, what you've described (a) would not be helped by such a method but (b) wouldn't need to be, since this case is already addressed by choosing to hide the element without disconnecting it. Unfortunately, React's agnosticism to elements having state/lifecycles goes pretty deep, but I think that's something React would have to solve - the platform can't really help (and a _lot_ of stuff indirectly hangs off of the current iframe disconnection behavior).

I thought maybe Portals might provide an alternative lifecycle here, but it looks like [their browsing contexts will also be destroyed on disconnection](https://wicg.github.io/portals/#concepts). I'm not sure if there was any discussion there about the possibility of contexts that stay "alive" after disconnection, but it seems maybe more plausible in that fresher territory than in the already-so-complicated world of iframes?

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

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

Received on Sunday, 17 April 2022 11:45:26 UTC