MCPcopy Create free account
hub / github.com/angular/components / _getShadowRoot

Function _getShadowRoot

src/cdk/platform/features/shadow-dom.ts:22–34  ·  view source on GitHub ↗
(element: HTMLElement)

Source from the content-addressed store, hash-verified

20
21/** Gets the shadow root of an element, if supported and the element is inside the Shadow DOM. */
22export function _getShadowRoot(element: HTMLElement): ShadowRoot | null {
23 if (_supportsShadowDom()) {
24 const rootNode = element.getRootNode ? element.getRootNode() : null;
25
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) {
29 return rootNode;
30 }
31 }
32
33 return null;
34}
35
36/**
37 * Gets the currently-focused element on the page while

Callers 6

ngOnInitMethod · 0.90
_getShadowRootMethod · 0.90
_getShadowRootMethod · 0.90
_getRootNodeMethod · 0.90
monitorMethod · 0.90

Calls 1

_supportsShadowDomFunction · 0.85

Tested by

no test coverage detected