Fix compilation error

This commit is contained in:
Alex Dima 2020-01-19 22:56:28 +01:00
parent cbf8bba0e7
commit e107e5c5bf
No known key found for this signature in database
GPG key ID: 6E58D7B045760DA0
2 changed files with 7 additions and 3 deletions

View file

@ -827,14 +827,18 @@ export function isShadowRoot(node: Node): node is ShadowRoot {
}
export function isInShadowDOM(domNode: Node): boolean {
return !!getShadowRoot(domNode);
}
export function getShadowRoot(domNode: Node): ShadowRoot | null {
while (domNode.parentNode) {
if (domNode === document.body) {
// reached the body
return false;
return null;
}
domNode = domNode.parentNode;
}
return isShadowRoot(domNode);
return isShadowRoot(domNode) ? domNode : null;
}
export function createStyleSheet(container: HTMLElement = document.getElementsByTagName('head')[0]): HTMLStyleElement {

View file

@ -68,7 +68,7 @@ export class CodeLensContribution implements IEditorContribution {
this._styleElement = dom.createStyleSheet(
dom.isInShadowDOM(this._editor.getContainerDomNode())
? this._editor.getContainerDomNode()
: null
: undefined
);
this._updateLensStyle();
}