Skip to content

feat: native re-parenting on web when supported - #87

Merged
kirillzyusko merged 1 commit into
mainfrom
feat/native-reparenting-on-web
Feb 10, 2026
Merged

kirillzyusko merged 1 commit into
mainfrom
feat/native-reparenting-on-web

Conversation

@kirillzyusko

@kirillzyusko kirillzyusko commented Feb 10, 2026 •

Copy link
Copy Markdown
Owner

📜 Description

Added ability to use native reparenting on web if it's supported. At the moment only Safari and Opera mobile doesn't support it.

💡 Motivation and Context

First of all it's worth to say that re-parenting has been implemented in very early specs of the web standard, but certain elements doesn't support it, for example iframe: whatwg/html#5484

And indeed it doesn't work as we expect:

Screen.Recording.2026-02-10.at.10.00.59.mov

As per original spec of moveBefore API:

image

So original re-parenting for video/lottie works well on all browsers, but moveBefore allows to go even further bringing true re-parenting for other elements, such as iframe/input with focus etc.

Yes, this API will not work on Safari and for iframe it will fallback to the old behavior and will reset state of iframe, but the ultimate goal of this library is to offer the best possible experience for devs, so I'll keep usage of moveBefore as it unlocks new horizons and I believe that Safari will add web support as well in the near future.

📢 Changelog

JS

  • added global.d.ts with support of new APIs that are not available in TS declaration yet;
  • use moveBefore API for re-parenting if it's available.

🤔 How Has This Been Tested?

Tested manually.

📸 Screenshots (if appropriate):

Before After
Screen.Recording.2026-02-10.at.10.00.59.mov
Screen.Recording.2026-02-10.at.09.59.20.mov

📝 Checklist

  • CI successfully passed
  • I added new mocks and corresponding unit-tests if library API was changed

@kirillzyusko kirillzyusko self-assigned this Feb 10, 2026
@kirillzyusko kirillzyusko added enhancement New feature or request 🌐 web Web specific labels Feb 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📊 Package size report

Current size Target Size Difference
29161 bytes 28693 bytes 468 bytes 📈

@kirillzyusko
kirillzyusko marked this pull request as ready for review February 10, 2026 09:06
@kirillzyusko
kirillzyusko merged commit 965ab26 into main Feb 10, 2026
12 checks passed
@kirillzyusko
kirillzyusko deleted the feat/native-reparenting-on-web branch February 10, 2026 09:10
@kirillzyusko kirillzyusko mentioned this pull request May 22, 2026
2 tasks done
kirillzyusko added a commit that referenced this pull request Jun 1, 2026
## 📜 Description

Reduced code duplication.

## 💡 Motivation and Context

<!-- Why is this change required? What problem does it solve? -->
<!-- If it fixes an open issue, please link to the issue here. -->

The original changes that added `if`-branching were here:
#87

In this PR I created separate function that moves an element between
containers.

Even though we have bigger code size and more lines such separation
helps to improve code readability, so let's sacrifice microcode
optimizations in sake of readability 🤞

## 📢 Changelog

<!-- High level overview of important changes -->
<!-- For example: fixed status bar manipulation; added new types
declarations; -->
<!-- If your changes don't affect one of platform/language below - then
remove this platform/language -->

### JS

- added `moveElementTo` helper function that switches implementation to
new/old API depending whether browser support it or not;

## 🤔 How Has This Been Tested?

Tested via e2e tests.

## 📸 Screenshots (if appropriate):

No visual changes.

## 📝 Checklist

- [x] CI successfully passed
- [x] I added new mocks and corresponding unit-tests if library API was
changed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request 🌐 web Web specific

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant