Isomorphic hydration: skip re-render when server HTML present
sx-mount now checks if the target element has children (server- rendered HTML). If so, skips the client re-render and only runs hydration (process-elements, hydrate-islands, hydrate-elements). This preserves server-rendered CSSX styling and avoids the flash of unstyled content that occurred when the client replaced the server HTML before re-rendering. 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-23T15:39:32Z";
|
||||
var SX_VERSION = "2026-03-23T16:18:55Z";
|
||||
|
||||
function isNil(x) { return x === NIL || x === null || x === undefined; }
|
||||
function isSxTruthy(x) { return x !== false && !isNil(x); }
|
||||
@@ -4627,16 +4627,12 @@ PRIMITIVES["hoist-head-elements-full"] = hoistHeadElementsFull;
|
||||
// sx-mount
|
||||
var sxMount = function(target, source, extraEnv) { return (function() {
|
||||
var el = resolveMountTarget(target);
|
||||
return (isSxTruthy(el) ? (function() {
|
||||
return (isSxTruthy(el) ? ((isSxTruthy(isEmpty(domChildList(el))) ? (function() {
|
||||
var node = sxRenderWithEnv(source, extraEnv);
|
||||
domSetTextContent(el, "");
|
||||
domAppend(el, node);
|
||||
hoistHeadElementsFull(el);
|
||||
processElements(el);
|
||||
sxHydrateElements(el);
|
||||
sxHydrateIslands(el);
|
||||
return runPostRenderHooks();
|
||||
})() : NIL);
|
||||
return hoistHeadElementsFull(el);
|
||||
})() : NIL), processElements(el), sxHydrateElements(el), sxHydrateIslands(el), runPostRenderHooks()) : NIL);
|
||||
})(); };
|
||||
PRIMITIVES["sx-mount"] = sxMount;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user