Skip to content

Commit

Permalink
fix(platform): avoid errors if ShadowRoot is not defined (angular#19124)
Browse files Browse the repository at this point in the history
Fixes potential errors if the `ShadowRoot` global is undefined.
  • Loading branch information
crisbeto authored Apr 23, 2020
1 parent eba622a commit 46babbd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/cdk/platform/features/shadow-dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export function _getShadowRoot(element: HTMLElement): Node | null {
if (_supportsShadowDom()) {
const rootNode = element.getRootNode ? element.getRootNode() : null;

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

0 comments on commit 46babbd

Please sign in to comment.