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
blockedBy[]
blocking[]
closedAtJan 14, 2026, 12:10 AM

Refactor StringBasedRenderer for API Parity (Separate Creation from Insertion)

Closed v11.21.0 airefactoringcore
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 added the ai label on Jan 13, 2026, 8:53 PM
tobiu added the refactoring label on Jan 13, 2026, 8:53 PM
tobiu added the core label on Jan 13, 2026, 8:53 PM
tobiu added parent issue #8601 on Jan 13, 2026, 8:54 PM
tobiu assigned to @tobiu on Jan 13, 2026, 8:59 PM
tobiu closed this issue on Jan 14, 2026, 12:10 AM
tobiu referenced in commit 7713cbb - "refactor(StringBasedRenderer): Consolidate logic into createNode and remove unused methods (#8617)" on Jan 14, 2026, 12:10 AM
tobiu referenced in commit 9e0e788 - "fix(DeltaUpdates): Unified insertion logic & scroll state fix for DomApiRenderer (#8617)" on Jan 14, 2026, 12:10 AM
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.