Skip to content

Commit 9296074

Browse files
committed
fix: don't query iframe document if contentWindow doesn't exist
1 parent a2766de commit 9296074

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/view/iframe/query-selector-all-iframe.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ export default function querySelectorAllIframe(selector: string) {
2828
const iframePossible = iframes.reduce<HTMLElement[]>(
2929
(acc, iframe) => [
3030
...acc,
31-
...querySelectorAll(iframe.contentWindow!.document, selector),
31+
...(iframe.contentWindow?.document
32+
? querySelectorAll(iframe.contentWindow.document, selector)
33+
: []),
3234
],
3335
[],
3436
);

src/view/use-style-marshal/use-style-marshal.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ export default function useStyleMarshal(contextId: ContextId, nonce?: string) {
6565
getHead(document),
6666
...(
6767
querySelectorAll(document, `[${prefix}-iframe]`) as HTMLIFrameElement[]
68-
).map((iframe) => getHead(iframe.contentWindow!.document)),
68+
)
69+
.filter((iframe) => iframe.contentWindow?.document)
70+
.map((iframe) => getHead(iframe.contentWindow!.document)),
6971
];
7072

7173
// Create initial style elements

0 commit comments

Comments
 (0)