fix(fit-addon): call getComputedStyle on the right window element
This commit is contained in:
committed by
Daniel Imms
parent
e7434a932d
commit
d67e73a4da
@@ -23,6 +23,17 @@ interface ITerminalDimensions {
|
|||||||
const MINIMUM_COLS = 2;
|
const MINIMUM_COLS = 2;
|
||||||
const MINIMUM_ROWS = 1;
|
const MINIMUM_ROWS = 1;
|
||||||
|
|
||||||
|
function getWindow(e: Node): Window {
|
||||||
|
if (e?.ownerDocument?.defaultView) {
|
||||||
|
return e.ownerDocument.defaultView.window;
|
||||||
|
}
|
||||||
|
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
function getComputedStyle(el: HTMLElement): CSSStyleDeclaration {
|
||||||
|
return getWindow(el).getComputedStyle(el, null);
|
||||||
|
}
|
||||||
|
|
||||||
export class FitAddon implements ITerminalAddon , IFitApi {
|
export class FitAddon implements ITerminalAddon , IFitApi {
|
||||||
private _terminal: Terminal | undefined;
|
private _terminal: Terminal | undefined;
|
||||||
|
|
||||||
@@ -69,10 +80,10 @@ export class FitAddon implements ITerminalAddon , IFitApi {
|
|||||||
? 0
|
? 0
|
||||||
: (this._terminal.options.overviewRuler?.width || ViewportConstants.DEFAULT_SCROLL_BAR_WIDTH));
|
: (this._terminal.options.overviewRuler?.width || ViewportConstants.DEFAULT_SCROLL_BAR_WIDTH));
|
||||||
|
|
||||||
const parentElementStyle = window.getComputedStyle(this._terminal.element.parentElement);
|
const parentElementStyle = getComputedStyle(this._terminal.element.parentElement);
|
||||||
const parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height'));
|
const parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height'));
|
||||||
const parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width')));
|
const parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width')));
|
||||||
const elementStyle = window.getComputedStyle(this._terminal.element);
|
const elementStyle = getComputedStyle(this._terminal.element);
|
||||||
const elementPadding = {
|
const elementPadding = {
|
||||||
top: parseInt(elementStyle.getPropertyValue('padding-top')),
|
top: parseInt(elementStyle.getPropertyValue('padding-top')),
|
||||||
bottom: parseInt(elementStyle.getPropertyValue('padding-bottom')),
|
bottom: parseInt(elementStyle.getPropertyValue('padding-bottom')),
|
||||||
|
|||||||
Reference in New Issue
Block a user