Skip to content

Commit c704912

Browse files
committed
fix(core): a torn-down runtime's pending readiness check no longer touches the next document
1 parent f03ee1c commit c704912

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

‎packages/core/src/runtime/init.test.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3798,6 +3798,29 @@ describe("initSandboxRuntimeModular", () => {
37983798
expect(window.__renderReady).toBe(true);
37993799
});
38003800

3801+
it("a torn-down runtime's pending readiness check leaves the next document alone", () => {
3802+
vi.useFakeTimers();
3803+
try {
3804+
const root = document.createElement("div");
3805+
root.setAttribute("data-composition-id", "main");
3806+
root.setAttribute("data-root", "true");
3807+
root.setAttribute("data-start", "0");
3808+
document.body.appendChild(root);
3809+
window.__timelines = { main: createMockTimeline(10) };
3810+
3811+
initSandboxRuntimeModular();
3812+
window.__hfRuntimeTeardown?.();
3813+
// The next document is still batching its timelines when the old check fires.
3814+
delete window.__renderReady;
3815+
window.__hfTimelinesBuilding = true;
3816+
vi.runAllTimers();
3817+
3818+
expect(window.__renderReady).toBeUndefined();
3819+
} finally {
3820+
vi.useRealTimers();
3821+
}
3822+
});
3823+
38013824
it("sets __renderReady even without a GSAP timeline (CSS/WAAPI compositions)", () => {
38023825
const root = document.createElement("div");
38033826
root.setAttribute("data-composition-id", "main");

‎packages/core/src/runtime/init.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4114,6 +4114,7 @@ export function initSandboxRuntimeModular(): void {
41144114
});
41154115

41164116
maybePublishRenderReady = () => {
4117+
if (state.tornDown) return;
41174118
if (!externalCompositionsReady) {
41184119
window.__renderReady = false;
41194120
return;

0 commit comments

Comments
 (0)