Files
xterm.js/src/browser/services/CoreBrowserService.ts
T
Pete Blois 057a8f6f1b Incorporate shadowRoot in focus calculation.
This adds a call to getRootNode to get either the Document or the
ShadowRoot to use when calculating whether the textarea has focus.

getRootNode is guarded for older browser compatibility (IE).
2020-11-09 13:12:03 -08:00

21 lines
559 B
TypeScript

/**
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
* @license MIT
*/
import { ICoreBrowserService } from './Services';
export class CoreBrowserService implements ICoreBrowserService {
public serviceBrand: undefined;
constructor(
private _textarea: HTMLTextAreaElement
) {
}
public get isFocused(): boolean {
const docOrShadowRoot = this._textarea.getRootNode ? this._textarea.getRootNode() as Document | ShadowRoot : document;
return docOrShadowRoot.activeElement === this._textarea && document.hasFocus();
}
}