From 6bd45daed608b1457d0ddaff90a713d33d2e9ef3 Mon Sep 17 00:00:00 2001 From: giles Date: Thu, 16 Apr 2026 14:00:12 +0000 Subject: [PATCH] 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) --- shared/static/wasm/sx/boot.sx | 5 +++-- web/boot.sx | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/shared/static/wasm/sx/boot.sx b/shared/static/wasm/sx/boot.sx index a5b319d1..6b416c40 100644 --- a/shared/static/wasm/sx/boot.sx +++ b/shared/static/wasm/sx/boot.sx @@ -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") diff --git a/web/boot.sx b/web/boot.sx index a5b319d1..6b416c40 100644 --- a/web/boot.sx +++ b/web/boot.sx @@ -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")