Skip to content

Commit 40014de

Browse files
committed
[scramjet] don't attempt to hook cross-origin iframes
1 parent 8e0488f commit 40014de

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

packages/scramjet/src/client/dom/element.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,10 +476,15 @@ export default function (client: ScramjetClient, self: typeof window) {
476476
const realwin = ctx.get() as Window;
477477
if (!realwin) return realwin;
478478

479-
if (!(SCRAMJETCLIENT in realwin)) {
480-
// hook the iframe before the client can start to steal globals out of it
481-
const newclient = new ScramjetClient(realwin);
482-
newclient.hook();
479+
try {
480+
if (!(SCRAMJETCLIENT in realwin)) {
481+
// hook the iframe before the client can start to steal globals out of it
482+
const newclient = new ScramjetClient(realwin);
483+
newclient.hook();
484+
}
485+
} catch {
486+
// cross-origin iframe, can't do anything here
487+
return realwin;
483488
}
484489

485490
return realwin;

0 commit comments

Comments
 (0)