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

@tsutsu yes, I faced this issue when using the `moveBefore()` method to improve the `hx-preserve` attribute in htmx.

My solution was to create a hidden "pantry" div that was connected to the main document, move all the preserved elements to that pantry element with `moveBefore()`, merge in the nodes created against a DocumentFragment, then swap the preserved elements into the new content with another `moveBefore()`.

This prevents the preserved elements from ever becoming disconnected and losing their state.  Maybe not the most elegant approach, but it works!

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

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

Received on Friday, 23 August 2024 21:24:53 UTC