LearnNewsExamplesServices
Frontmatter
id8598
titleRefine Chimera safeguard in VDom.syncVdomState
stateClosed
labels
enhancementaicore
assigneestobiu
createdAtJan 13, 2026, 2:59 PM
updatedAtJan 13, 2026, 3:08 PM
githubUrlhttps://github.com/neomjs/neo/issues/8598
authortobiu
commentsCount2
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJan 13, 2026, 3:08 PM

Refine Chimera safeguard in VDom.syncVdomState

Closed v11.21.0 enhancementaicore
tobiu
tobiu commented on Jan 13, 2026, 2:59 PM

Currently, VDom.syncVdomState aborts completely if the root node tags mismatch (e.g. div vs ul). This prevents child nodes from synchronizing their IDs/state, leading to unnecessary DOM destruction and recreation when a wrapper tag changes.

The fix is to refine the safeguard:

  1. Skip property synchronization (ID, scrollTop) for the mismatched node itself.
  2. Continue recursion to attempt synchronization of child nodes (which will have their own tag checks).
tobiu added the enhancement label on Jan 13, 2026, 2:59 PM
tobiu added the ai label on Jan 13, 2026, 2:59 PM
tobiu added the core label on Jan 13, 2026, 2:59 PM
tobiu referenced in commit ffb9f5c - "enhancement: Refine Chimera safeguard in VDom.syncVdomState (#8598) on Jan 13, 2026, 3:03 PM
tobiu assigned to @tobiu on Jan 13, 2026, 3:03 PM
tobiu
tobiu Jan 13, 2026, 3:03 PM

Input from Gemini 3 Pro:

✦ I have refined the safeguard in VDom.syncVdomState. It no longer aborts completely on tag mismatch. Instead:

  1. It skips syncing ID/Scroll for the mismatched node (preventing Chimera on the parent).
  2. It continues to recurse into children, allowing them to sync their IDs if their tags match.

This enables child node preservation (moving) when a parent tag changes. Changes pushed to dev.

tobiu referenced in commit 0725b71 - "enhancement: Preserve scroll state during tag name changes (#8598) on Jan 13, 2026, 3:06 PM
tobiu
tobiu Jan 13, 2026, 3:07 PM

Input from Gemini 3 Pro:

✦ I have expanded the scope of this ticket to include Scroll State Preservation during Tag Changes.

Originally, VDom.syncVdomState prevented any state synchronization if a tag mismatch was detected to avoid "Chimera" node corruption (e.g., a ul receiving a li ID). However, this had the side effect of also preventing scroll state synchronization (scrollTop, scrollLeft), causing scroll jumps when a container's tag was changed (e.g., div -> section).

Updates:

  1. src/util/VDom.mjs:

    • Refined the safeguard: I moved the scroll synchronization logic outside the !tagMismatch block.
    • Result: The worker/VDOM now correctly captures and preserves the scroll position from the old VNode even if the new VDOM has a different tag name. The ID synchronization remains protected inside the safeguard to prevent Chimera corruption.
  2. src/main/DeltaUpdates.mjs:

    • Updated changeNodeName to explicitly copy scrollTop and scrollLeft from the old DOM node to the new clone before replacement.
    • Result: The physical DOM replacement operation is now seamless regarding scroll position.

These changes ensure that semantic tag changes are non-destructive to both child structure and scroll state.

tobiu closed this issue on Jan 13, 2026, 3:08 PM