Skip to content

Commit d5ed4c0

Browse files
committed
fix: add safety checks for container and detached window element
1 parent 1380cc3 commit d5ed4c0

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/script/components/Modals/PrimaryModal/PrimaryModalShell/PrimaryModalShell.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,14 @@ export const PrimaryModalShell = ({
5656
return undefined;
5757
}
5858

59-
const detachedWindowRoot = (container as HTMLElement).querySelector?.('#detached-window') as HTMLElement;
59+
// Safety check
60+
const element = container instanceof HTMLElement ? container : null;
61+
if (!element?.querySelector) {
62+
return undefined;
63+
}
6064

61-
if (!detachedWindowRoot) {
65+
const detachedWindowRoot = element.querySelector('#detached-window');
66+
if (!detachedWindowRoot || !(detachedWindowRoot instanceof HTMLElement)) {
6267
return undefined;
6368
}
6469

0 commit comments

Comments
 (0)