moveElementInto
Move an element into a new parent, preserving its state where the platform allows it.
Uses Node.moveBefore (Chromium 133+, Firefox 144+) when both the element and parent are connected to the same document — this moves the element without resetting its state, so iframes don't reload and media keeps playing. Otherwise (older browsers, disconnected nodes, or a cross-document move) it falls back to appendChild, which moves the element but resets its state like an iframe reload.
This is the primitive tldraw uses to adopt ShapeUtil.getAppOwnedElement elements, exposed so apps can perform symmetric state-preserving moves from ShapeUtil.onReleaseAppOwnedElement — for example moving an element to an off-canvas parking lot between editor sessions.
function moveElementInto(parent: HTMLElement, element: HTMLElement): void;Parameters
| Name | Description |
|---|---|
| The element to move |
| The element to move. |
Returns
void;