LearnNewsExamplesServices
Frontmatter
id8139
titleSupport saveScrollPosition in StringBasedRenderer
stateClosed
labels
enhancementaicore
assigneestobiu
createdAtDec 17, 2025, 3:55 PM
updatedAtDec 17, 2025, 4:48 PM
githubUrlhttps://github.com/neomjs/neo/issues/8139
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtDec 17, 2025, 4:48 PM

Support saveScrollPosition in StringBasedRenderer

Closed v11.17.0 enhancementaicore
tobiu
tobiu commented on Dec 17, 2025, 3:55 PM

Context

Ticket #8138 added support for scrollTop and scrollLeft in DomApiRenderer by queuing post-mount updates. We need to support the same feature for StringBasedRenderer (used when Neo.config.useDomApiRenderer is false). Since parsing HTML strings in the main thread to extract these properties is expensive, we will offload this work to the VDom worker.

Problem

The current string generation logic in Neo.vdom.util.StringFromVnode only produces an HTML string. It ignores scrollTop and scrollLeft properties on VNodes, meaning scroll state is lost when mounting via outerHTML.

Goal

Update the VDom-to-String generation process to produce a sidecar map of nodes requiring scroll updates, and update the renderer to apply them.

Implementation Details

1. VDom Worker Side

  • src/vdom/util/StringFromVnode.mjs:
    • Update create() to accept a postMountUpdates array (similar to the movedNodes map).
    • When processing a VNode, if it has scrollTop or scrollLeft, add an entry to postMountUpdates: {id, scrollLeft, scrollTop}.
  • src/vdom/Helper.mjs:
    • Update create() method.
    • Initialize postMountUpdates array.
    • Pass it to StringFromVnode.create().
    • Include postMountUpdates in the returned object if it has entries.
    • Update insertNode to include postMountUpdates in the delta object.

2. Main Thread Side

  • src/main/DeltaUpdates.mjs:
    • Update insertNode to pass postMountUpdates to StringBasedRenderer.insertNodeAsString.
  • src/main/render/StringBasedRenderer.mjs:
    • Update insertNodeAsString to accept postMountUpdates.
    • After inserting the HTML, iterate through postMountUpdates and apply the scroll values to the corresponding DOM nodes (lookup by ID).
tobiu added the enhancement label on Dec 17, 2025, 3:55 PM
tobiu added the ai label on Dec 17, 2025, 3:55 PM
tobiu added the core label on Dec 17, 2025, 3:55 PM
tobiu assigned to @tobiu on Dec 17, 2025, 3:56 PM
tobiu referenced in commit f255fdd - "Support saveScrollPosition in StringBasedRenderer #8139" on Dec 17, 2025, 4:16 PM
tobiu closed this issue on Dec 17, 2025, 4:48 PM