Merge pull request #2497 from Tyriar/warn_not_throw
Warn don't throw when open is called on unattached element
This commit is contained in:
@@ -508,6 +508,10 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
|
|||||||
throw new Error('Terminal requires a parent element.');
|
throw new Error('Terminal requires a parent element.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!document.body.contains(parent)) {
|
||||||
|
this._logService.warn('Terminal.open was called on an element that was not attached to the DOM');
|
||||||
|
}
|
||||||
|
|
||||||
this._document = this._parent.ownerDocument;
|
this._document = this._parent.ownerDocument;
|
||||||
|
|
||||||
// Create main element container
|
// Create main element container
|
||||||
|
|||||||
@@ -56,9 +56,6 @@ export class Terminal implements ITerminalApi {
|
|||||||
this._core.resize(columns, rows);
|
this._core.resize(columns, rows);
|
||||||
}
|
}
|
||||||
public open(parent: HTMLElement): void {
|
public open(parent: HTMLElement): void {
|
||||||
if (!document.body.contains(parent)) {
|
|
||||||
throw new Error('open must be called on an element that is attached to the DOM');
|
|
||||||
}
|
|
||||||
this._core.open(parent);
|
this._core.open(parent);
|
||||||
}
|
}
|
||||||
public attachCustomKeyEventHandler(customKeyEventHandler: (event: KeyboardEvent) => boolean): void {
|
public attachCustomKeyEventHandler(customKeyEventHandler: (event: KeyboardEvent) => boolean): void {
|
||||||
|
|||||||
Reference in New Issue
Block a user