Re: [whatwg/dom] Atomic move operation for element reparenting & reordering (Issue #1255)

yuval-a left a comment (whatwg/dom#1255)

Hi.
I found out about moveBefore just now while trying to implement something is a components framework I'm building (actually its version 2.0 - SproutJS).

I have a "sub" DOM tree - I'd like to "detach" it - manipulate some of its children - then "attach it back".

"Untouched" children would fire connectedCallback and disconnectedCallback --- not the behavior I wanted.
moveBefore seems to be the right thing to use to solve this (other than using flags, which was my previous option, but === a lof of "if"s overhead.

However there's this limitation where I can only "move" with moveBefore to an already connected DOM.
Why? Why does that limitation exist?

I mean, I can always have a "hidden bank DOM" for this, but it's kind of ugly.

So, I have this use case. Basically I'd like to be able to "temporarily detach" DOM - preserving everything about it (that is possible) - then possibly attaching it back (and if not, I could call some "release" function that will actually permanently  detach it, then it can call disconnectedCallback.

For now I think I'll use the "hidden DOM container" method...

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

Message ID: <whatwg/dom/issues/1255/2822519950@github.com>

Received on Tuesday, 22 April 2025 21:27:12 UTC