From 52ae8fc14b333efb909f1f4566d53cff928b405a Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 7 Oct 2019 10:21:34 -0700 Subject: [PATCH] Throw when open is called on element not on DOM Fixes #1158 --- src/public/Terminal.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/public/Terminal.ts b/src/public/Terminal.ts index b8a70ff7..70a77fd2 100644 --- a/src/public/Terminal.ts +++ b/src/public/Terminal.ts @@ -56,6 +56,9 @@ export class Terminal implements ITerminalApi { this._core.resize(columns, rows); } 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); } public attachCustomKeyEventHandler(customKeyEventHandler: (event: KeyboardEvent) => boolean): void {