DOM-preserving hydration — SSR DOM stays, event listeners attach in place

Scope-based cursor walks the existing SSR DOM during island hydration
instead of creating new elements and calling replaceChildren. The
hydration scope (sx-hydrating) propagates through define-library via
scope-push!/peek/pop!, solving the env isolation that broke the
previous set!-based approach.

Changes:
- adapter-dom.sx: hydrating?, hydrate-next-node, hydrate-enter/exit-element
  helpers. render-to-dom reuses text nodes. render-dom-element reuses
  elements by tag match, skips dom-append. reactive-text/cek-reactive-text
  reuse existing text nodes. render-dom-fragment/lake/marsh skip append.
  dispatch-render-form (if/when/cond) injects markers into existing DOM.
- boot.sx: hydrate-island pushes cursor scope, skips replaceChildren.
  On mismatch error, falls back to full re-render.

Result: zero DOM destruction, zero visual flash, event listeners
attached to original SSR elements. Stepper clicks verified working.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-10 11:46:41 +00:00
parent 89ffb02b20
commit a2a4d17d53
7 changed files with 2855 additions and 2534 deletions

View File

@@ -536,6 +536,7 @@
"SVG_NS",
"MATH_NS",
"island-scope?",
"hydrating?",
"contains-deref?",
"dom-on",
"render-to-dom",