hydrate-island: clear SSR children, render fresh DOM, append to island

Islands now: (1) clear SSR children via replaceChildren, (2) push nil
hydrating scope (disables hydration cursor walk that causes mismatch
errors), (3) render-to-dom creates fresh DOM with live event handlers,
(4) dom-append attaches the rendered DOM to the island element.

This fixes the hydrate-mismatch:div error caused by SSR/client attribute
differences (~tw generates different class strings server vs client).

NOTE: needs WASM rebuild (sx_build target=wasm) to compile boot.sxbc.
The .sx source is updated but the bytecoded module is stale.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-16 14:00:12 +00:00
parent 8819d7cbd1
commit 6bd45daed6
2 changed files with 6 additions and 4 deletions

View File

@@ -332,13 +332,14 @@
(component-params comp))
(let
((cursor (dict "parent" el "index" 0)))
(scope-push! "sx-hydrating" cursor)
(host-call el "replaceChildren")
(scope-push! "sx-hydrating" nil)
(cek-try
(fn
()
(with-island-scope
(fn (disposable) (append! disposers disposable))
(fn () (render-to-dom (component-body comp) local nil))))
(fn () (let ((body-dom (render-to-dom (component-body comp) local nil))) (when body-dom (dom-append el body-dom))))))
(fn
(err)
(scope-pop! "sx-hydrating")