From 98d25607a9ca9ce499540e3c34ee819e0ea2480a Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 26 Dec 2017 02:22:09 -0800 Subject: [PATCH 1/2] Prevent exception when setting bellSound before open Fixes #1165 --- src/Terminal.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Terminal.ts b/src/Terminal.ts index b685c8cd..ce683912 100644 --- a/src/Terminal.ts +++ b/src/Terminal.ts @@ -2116,6 +2116,11 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT } private syncBellSound(): void { + // Don't update anything if the terminal has not been opened yet + if (!this.element) { + return; + } + if (this.soundBell() && this.bellAudioElement) { this.bellAudioElement.setAttribute('src', this.options.bellSound); } else if (this.soundBell()) { From f24a94b3411d85983f97ac784f6afe0dac815bb4 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 26 Dec 2017 04:06:00 -0800 Subject: [PATCH 2/2] Move syncBellSound after helperContainer init --- src/Terminal.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Terminal.ts b/src/Terminal.ts index ce683912..afea5e90 100644 --- a/src/Terminal.ts +++ b/src/Terminal.ts @@ -593,9 +593,6 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT this.viewportScrollArea.classList.add('xterm-scroll-area'); this.viewportElement.appendChild(this.viewportScrollArea); - // preload audio - this.syncBellSound(); - this._mouseZoneManager = new MouseZoneManager(this); this.on('scroll', () => this._mouseZoneManager.clearAll()); this.linkifier.attachToDom(this._mouseZoneManager); @@ -625,6 +622,9 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT this.helperContainer.appendChild(this.charSizeStyleElement); this.charMeasure = new CharMeasure(document, this.helperContainer); + // Preload audio, this relied on helperContainer + this.syncBellSound(); + // Performance: Add viewport and helper elements from the fragment this.element.appendChild(fragment);