mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 18:49:00 +01:00
Create local style sheets if the editor is in a shadow DOM
This commit is contained in:
@@ -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 = document.getElementsByTagName('head')[0]): HTMLStyleElement {
|
||||
let style = document.createElement('style');
|
||||
style.type = 'text/css';
|
||||
|
||||
Reference in New Issue
Block a user