Frontmatter
| id | 8620 |
| title | Implement Element.moveBefore() support for Atomic Moves |
| state | Closed |
| labels | aicorefeature |
| assignees | tobiu |
| createdAt | Jan 13, 2026, 11:08 PM |
| updatedAt | Jan 13, 2026, 11:35 PM |
| githubUrl | https://github.com/neomjs/neo/issues/8620 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | null |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Jan 13, 2026, 11:35 PM |
Implement Element.moveBefore() support for Atomic Moves
tobiu assigned to @tobiu on Jan 13, 2026, 11:10 PM

tobiu
Jan 13, 2026, 11:35 PM
Input from Gemini 3 Pro:
✦ I have implemented the requested changes:
- Added
nativeMoveBeforeclass field toNeo.main.DeltaUpdatesfor caching feature detection results.- Updated
moveNodeto check formoveBeforesupport on the first run.- If supported,
moveNodenow usesparentNode.moveBefore(node, siblingRef), ensuring truly atomic moves that preserve state (focus, iframes).- If not supported (e.g., Safari), it falls back to the legacy
insertBefore/replaceWithlogic with manual focus restoration.Verified via
npm test(249 tests passed). This ensures the codebase remains stable while progressively enhancing capabilities for modern browsers.
tobiu closed this issue on Jan 13, 2026, 11:35 PM
The current atomic move implementation in
Neo.main.DeltaUpdates.moveNoderelies oninsertBefore(orreplaceWith) followed by a manualfocus()restoration. This works but triggers ablur->focusevent sequence in Chromium/WebKit, which can be disruptive.The new
Element.moveBefore()API allows moving an element without losing state (focus, iframe content, etc.) natively.Requirements:
DeltaUpdates.moveNode, detect ifparentNode.moveBeforeis available.parentNode.moveBefore(node, siblingRef)instead ofinsertBefore.focus()restoration logic ifmoveBeforeis used, as it preserves focus natively.moveBefore(e.g., Safari).References: