Skip to content

Commit 7fc039a

Browse files
committed
fix(web): trim the #3971 park gate (re-enter hydrate instead of splitting it)
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_018LY7F9czoRqdMEvk2QwPr1
1 parent 709c06d commit 7fc039a

1 file changed

Lines changed: 10 additions & 25 deletions

File tree

‎packages/web/src/client.ts‎

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2357,36 +2357,21 @@ export function hydrate(code, element, options = {}) {
23572357
// is set by the server bootstrap only: a hand-built `_$HY` never parks.
23582358
if (hy.s && !hy.s[id] && !hy.s[""] && !hy.done && document.readyState === "loading") {
23592359
let started, disposer;
2360-
const start = () => {
2361-
if (started) return;
2362-
started = true;
2363-
document.removeEventListener("DOMContentLoaded", start);
2364-
disposer = hydrateRoot(code, element, options);
2365-
};
2366-
// The marker calls `_$HY.sw(renderId)`; the start rides a microtask so
2367-
// it runs once the marker script has finished, before parsing resumes.
2368-
const parked = hy.sp || (hy.sp = {});
2369-
(parked[id] || (parked[id] = [])).push(start);
2370-
// A root render's ("") shell covers every id re-entered inside it.
2371-
hy.sw = key => {
2372-
for (const k in parked) {
2373-
if (key && k !== key) continue;
2374-
for (const f of parked[k]) queueMicrotask(f);
2375-
delete parked[k];
2376-
}
2377-
};
2378-
document.addEventListener("DOMContentLoaded", start);
2360+
// Re-entering hydrate() passes the gate: the marker has set its key, or
2361+
// the parser is done.
2362+
const start = () => started || ((started = true), (disposer = hydrate(code, element, options)));
2363+
// The marker calls `_$HY.sw(renderId)`; starts ride a microtask so they
2364+
// run once the marker script has finished, before parsing resumes. A
2365+
// root render's ("") marker covers every id re-entered inside it.
2366+
(hy.sp || (hy.sp = [])).push([id, start]);
2367+
hy.sw = key => hy.sp.forEach(([k, f]) => (!key || k === key) && queueMicrotask(f));
2368+
document.addEventListener("DOMContentLoaded", start, { once: true });
23792369
return () => {
23802370
started = true;
2381-
document.removeEventListener("DOMContentLoaded", start);
23822371
disposer && disposer();
23832372
};
23842373
}
2385-
return hydrateRoot(code, element, options);
2386-
}
2387-
2388-
function hydrateRoot(code, element, options) {
2389-
if (globalThis._$HY.done) return render(code, element, [...element.childNodes], options);
2374+
if (hy.done) return render(code, element, [...element.childNodes], options);
23902375
// #3081: the server splices useHead's charset/base prelude immediately
23912376
// after the <head> open tag — a byte-placement constraint (charset within
23922377
// the first 1024 bytes, base before URL-bearing tags) the parser has

0 commit comments

Comments
 (0)