demo · v133
Element.moveBefore()
Move an <iframe> between two parents with the old appendChild API (reloads, loses state) versus the new moveBefore (preserves the iframe's load count). Counter visible inside the iframe.
parent A
parent B
moveBefore() called
0
appendChild() called
0
checking support…
the code
// Before: reparent reloads the iframe, restarts animations, drops focus.
parentB.appendChild(iframe);
// After (Chrome 133+): state-preserving move.
parentB.moveBefore(iframe, null);
see also
- DOM State-Preserving Move — feature index
- ChromeStatus entry
- WHATWG DOM issue 1255