test(sdk): cover attachSync against a detached iframe

This commit is contained in:
Vance Ingalls
2026-07-09 11:52:13 -07:00
parent ed9df3f57d
commit 0e08543561
@@ -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();
});
});