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).
Context
Ticket #8138 added support for
scrollTopandscrollLeftinDomApiRendererby queuing post-mount updates. We need to support the same feature forStringBasedRenderer(used whenNeo.config.useDomApiRendereris 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.StringFromVnodeonly produces an HTML string. It ignoresscrollTopandscrollLeftproperties on VNodes, meaning scroll state is lost when mounting viaouterHTML.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:create()to accept apostMountUpdatesarray (similar to themovedNodesmap).scrollToporscrollLeft, add an entry topostMountUpdates:{id, scrollLeft, scrollTop}.src/vdom/Helper.mjs:create()method.postMountUpdatesarray.StringFromVnode.create().postMountUpdatesin the returned object if it has entries.insertNodeto includepostMountUpdatesin the delta object.2. Main Thread Side
src/main/DeltaUpdates.mjs:insertNodeto passpostMountUpdatestoStringBasedRenderer.insertNodeAsString.src/main/render/StringBasedRenderer.mjs:insertNodeAsStringto acceptpostMountUpdates.postMountUpdatesand apply the scroll values to the corresponding DOM nodes (lookup by ID).