Skip to content

Write HTML. Render video. Built for agents.

test(sdk): cover attachSync against a detached iframe

Vance Ingalls0e085435615a
diff --git a/packages/sdk/src/adapters/iframe.sync.test.ts b/packages/sdk/src/adapters/iframe.sync.test.ts
index fdfabe9d9a..0ef244d704 100644
--- a/packages/sdk/src/adapters/iframe.sync.test.ts
+++ b/packages/sdk/src/adapters/iframe.sync.test.ts
@@ -151,4 +151,15 @@ window.__timelines = { t: tl };</script>
const liveStyle = iframe.contentDocument!.querySelector("style")!.textContent ?? "";
expect(liveStyle).toContain("green");
});
+
+ it("does not throw when a patch arrives after the iframe is removed from the DOM", async () => {
+ const iframe = mountIframe(BASE_HTML);
+ const comp = await openComposition(BASE_HTML);
+ const adapter = createIframePreviewAdapter(iframe);
+ adapter.attachSync(comp);
+
+ iframe.remove(); // contentDocument becomes null (or inaccessible) once detached
+
+ expect(() => comp.setStyle("hf-title", { color: "#0f0" })).not.toThrow();
+ });
});