Skip to content

Commit 46babbd

Browse files
authored
fix(platform): avoid errors if ShadowRoot is not defined (#19124)
Fixes potential errors if the `ShadowRoot` global is undefined.
1 parent eba622a commit 46babbd

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/cdk/platform/features/shadow-dom.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ export function _getShadowRoot(element: HTMLElement): Node | null {
2323
if (_supportsShadowDom()) {
2424
const rootNode = element.getRootNode ? element.getRootNode() : null;
2525

26-
if (rootNode instanceof ShadowRoot) {
26+
// Note that this should be caught by `_supportsShadowDom`, but some
27+
// teams have been able to hit this code path on unsupported browsers.
28+
if (typeof ShadowRoot !== 'undefined' && ShadowRoot && rootNode instanceof ShadowRoot) {
2729
return rootNode;
2830
}
2931
}

0 commit comments

Comments
 (0)