Skip to content

Commit bd892b6

Browse files
authored
revert to document.write again; cesiumjs doesn't like srcdoc, period. (#258)
* revert to document.write again; cesiumjs doesn't like srcdoc, period. * Update server.ts
1 parent 231f23f commit bd892b6

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

examples/basic-host/src/sandbox.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,17 @@ window.addEventListener("message", async (event) => {
9595
inner.setAttribute("allow", allowAttribute);
9696
}
9797
if (typeof html === "string") {
98-
inner.srcdoc = html;
99-
} else {
100-
console.error("[Sandbox] Missing or invalid HTML content in sandbox-resource-ready notification.");
98+
// Use document.write instead of srcdoc (which the CesiumJS Map won't work with)
99+
const doc = inner.contentDocument || inner.contentWindow?.document;
100+
if (doc) {
101+
doc.open();
102+
doc.write(html);
103+
doc.close();
104+
} else {
105+
// Fallback to srcdoc if document is not accessible
106+
console.warn("[Sandbox] document.write not available, falling back to srcdoc");
107+
inner.srcdoc = html;
108+
}
101109
}
102110
} else {
103111
if (inner && inner.contentWindow) {

0 commit comments

Comments
 (0)