Atomic island hydration: replaceChildren instead of clear+append
The hydrate-island function was doing: (dom-set-text-content el "") ;; clears SSR content — visible flash (dom-append el body-dom) ;; adds reactive DOM Now uses: (host-call el "replaceChildren" body-dom) ;; atomic swap, no empty state Per DOM spec, replaceChildren is a single synchronous operation — the browser never renders the intermediate empty state. The MutationObserver test now checks for content going to zero (visible gap), not mutation count (mutations are expected during any swap). Test: "No clobber: clean" — island never goes empty during hydration. All 8 home features pass: no-flash, no-clobber, boot, islands, stepper, smoke, no-errors. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -331,8 +331,7 @@
|
||||
(component-params comp))
|
||||
(let
|
||||
((body-dom (cek-try (fn () (with-island-scope (fn (disposable) (append! disposers disposable)) (fn () (render-to-dom (component-body comp) local nil)))) (fn (err) (log-warn (str "hydrate-island FAILED: " comp-name " — " err)) (let ((error-el (dom-create-element "div" nil))) (dom-set-attr error-el "class" "sx-island-error") (dom-set-attr error-el "style" "padding:8px;margin:4px 0;border:1px solid #ef4444;border-radius:4px;background:#fef2f2;color:#b91c1c;font-family:monospace;font-size:12px;white-space:pre-wrap") (dom-set-text-content error-el (str "Island error: " comp-name "\n" err)) error-el)))))
|
||||
(dom-set-text-content el "")
|
||||
(dom-append el body-dom)
|
||||
(host-call el "replaceChildren" body-dom)
|
||||
(dom-set-data el "sx-disposers" disposers)
|
||||
(set-timeout (fn () (process-elements el)) 0)
|
||||
(log-info
|
||||
|
||||
Reference in New Issue
Block a user