Skip to content

Conversation

@mathieumahe
Copy link

Description

This PR updates the code to use the new moveBefore() method when it is available, and falls back to insertBefore() otherwise.

Unlike insertBefore(), moveBefore() allows moving a node without removing it from the DOM, which preserves its internal state and ongoing behavior.

This has several important benefits:

  • Component state is preserved
  • CSS animations are not reset
  • Embedded content such as iframes is not reloaded (e.g. TinyMCE editors, YouTube videos, etc.)

References

MDN: Element.moveBefore()
https://developer.mozilla.org/en-US/docs/Web/API/Element/moveBefore#movebefore_constraints

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant