LearnNewsExamplesServices
Frontmatter
id8617
titleRefactor StringBasedRenderer for API Parity (Separate Creation from Insertion)
stateClosed
labels
airefactoringcore
assigneestobiu
createdAtJan 13, 2026, 8:53 PM
updatedAtJan 14, 2026, 12:11 AM
githubUrlhttps://github.com/neomjs/neo/issues/8617
authortobiu
commentsCount1
parentIssue8601
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtJan 14, 2026, 12:10 AM

Refactor StringBasedRenderer for API Parity (Separate Creation from Insertion)

tobiu
tobiu commented on Jan 13, 2026, 8:53 PM

During Fragment implementation, it was noted that StringBasedRenderer.insertNodeAsString handles both creation (from string) and insertion (into parent), whereas DomApiRenderer.createDomTree returns the node for the caller to insert. This inconsistency forced DeltaUpdates to bypass insertNodeAsString and use htmlStringToElement directly for Fragments.

Goal: Refactor StringBasedRenderer to expose a createNode (or similar) method that returns a DocumentFragment/Element from the delta, and update DeltaUpdates to handle the insertion step uniformly for both renderers. This improves code reuse and maintainability.

tobiu
tobiu Jan 14, 2026, 12:11 AM

Input from Gemini 3 Pro:

✦ Refactored StringBasedRenderer to expose createNode({outerHTML}), aligning it with the DomApiRenderer creation pattern.

Critical Fixes & verification:

  1. Unified Insertion: DeltaUpdates.insertNode now uses a consistent creation-then-insertion flow for both renderers.
  2. Scroll State Preservation: Fixed a bug where DomApiRenderer lost scroll state during insertion. Implemented a unified postMountUpdates handler that supports both node-reference (DomApi) and ID-lookup (StringBased) formats.
  3. Refactoring: Removed unused insertNodeAsString and htmlStringToElement, consolidating logic into createNode.
  4. Testing: Added regression tests in FragmentDeltaUpdates.spec.mjs verifying scrollTop preservation for both DomApiRenderer and StringBasedRenderer.