Merge remote-tracking branch 'origin/master' into pr/lmvco/88536

This commit is contained in:
Alex Dima
2020-01-19 21:42:42 +01:00
13 changed files with 190 additions and 33 deletions

View File

@@ -820,6 +820,23 @@ export function hasParentWithClass(node: HTMLElement, clazz: string, stopAtClazz
return !!findParentWithClass(node, clazz, stopAtClazzOrNode);
}
export function isShadowRoot(node: Node): node is ShadowRoot {
return (
node && !!(<ShadowRoot>node).host && !!(<ShadowRoot>node).mode
);
}
export function isInShadowDOM(domNode: Node): boolean {
while (domNode.parentNode) {
if (domNode === document.body) {
// reached the body
return false;
}
domNode = domNode.parentNode;
}
return isShadowRoot(domNode);
}
export function createStyleSheet(container: HTMLElement | null = null): HTMLStyleElement {
if (!container) {
if ((window as any).monacoShadowRoot) {