Fix island state preservation: revert force-dispose to dispose
The ocaml branch introduced force-dispose-islands-in for outerHTML swaps, which destroyed hydrated islands (including their live signals). This broke the core hypermedia+reactive pattern: the header island's colour state was lost on navigation, and lakes weren't being morph-updated. Reverted to production behaviour: dispose-islands-in skips hydrated islands. The morph algorithm then preserves them (matching by data-sx-island name) and only morphs their lake content. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
// =========================================================================
|
||||
|
||||
var NIL = Object.freeze({ _nil: true, toString: function() { return "nil"; } });
|
||||
var SX_VERSION = "2026-03-23T16:18:55Z";
|
||||
var SX_VERSION = "2026-03-23T17:58:42Z";
|
||||
|
||||
function isNil(x) { return x === NIL || x === null || x === undefined; }
|
||||
function isSxTruthy(x) { return x !== false && !isNil(x); }
|
||||
@@ -4039,7 +4039,7 @@ return processElements(t); });
|
||||
return (function() {
|
||||
var selectSel = domGetAttr(el, "sx-select");
|
||||
var content = (isSxTruthy(selectSel) ? selectFromContainer(container, selectSel) : childrenToFragment(container));
|
||||
(isSxTruthy((swapStyle == "outerHTML")) ? forceDisposeIslandsIn(target) : disposeIslandsIn(target));
|
||||
disposeIslandsIn(target);
|
||||
return withTransition(useTransition, function() { swapDomNodes(target, content, swapStyle);
|
||||
return postSwap(target); });
|
||||
})();
|
||||
|
||||
@@ -292,12 +292,10 @@
|
||||
(content (if select-sel
|
||||
(select-from-container container select-sel)
|
||||
(children-to-fragment container))))
|
||||
;; Dispose old islands before swap.
|
||||
;; outerHTML replaces the target entirely — force-dispose all islands.
|
||||
;; Other swap styles (innerHTML, beforeend, etc.) may preserve islands.
|
||||
(if (= swap-style "outerHTML")
|
||||
(force-dispose-islands-in target)
|
||||
(dispose-islands-in target))
|
||||
;; Dispose non-hydrated islands before swap.
|
||||
;; Hydrated islands are preserved — the morph algorithm
|
||||
;; keeps their live signals and only morphs their lakes.
|
||||
(dispose-islands-in target)
|
||||
;; Swap
|
||||
(with-transition use-transition
|
||||
(fn ()
|
||||
|
||||
Reference in New Issue
Block a user