fix(refresher): correctly select shadow root on older browsers (#21237)

This commit is contained in:
Liam DeBeasi
2020-05-08 11:54:57 -04:00
committed by GitHub
parent f334e83a43
commit f23f1cb37e
2 changed files with 17 additions and 4 deletions

View File

@@ -5,6 +5,19 @@ import { Side } from '../interface';
declare const __zone_symbol__requestAnimationFrame: any;
declare const requestAnimationFrame: any;
/**
* Gets the root context of a shadow dom element
* On newer browsers this will be the shadowRoot,
* but for older browser this may just be the
* element itself.
*
* Useful for whenever you need to explicitly
* do "myElement.shadowRoot!.querySelector(...)".
*/
export const getElementRoot = (el: HTMLElement, fallback: HTMLElement = el) => {
return el.shadowRoot || fallback;
};
/**
* Patched version of requestAnimationFrame that avoids ngzone
* Use only when you know ngzone should not run