Combine preloadBellSound and syncBellSound into the same function

This commit is contained in:
npezza93
2017-08-19 18:03:04 -04:00
parent 81cb30833f
commit f983e4eb6b
+7 -11
View File
@@ -485,8 +485,8 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
this.viewport.syncScrollArea();
break;
case 'tabStopWidth': this.setupStops(); break;
case 'bellSound': this.syncBellSound(); break;
case 'bellStyle': this.preloadBellSound(); break;
case 'bellSound':
case 'bellStyle': this.syncBellSound(); break;
}
}
@@ -695,7 +695,7 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
this.viewportElement.appendChild(this.viewportScrollArea);
// preload audio
this.preloadBellSound();
this.syncBellSound();
// Create the selection container.
this.selectionContainer = document.createElement('div');
@@ -2294,8 +2294,10 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
this.options.bellStyle === 'both';
}
private preloadBellSound(): void {
if (this.soundBell()) {
private syncBellSound(): void {
if (this.soundBell() && this.bellAudioElement) {
this.bellAudioElement.setAttribute('src', this.options.bellSound);
} else if (this.soundBell()) {
this.bellAudioElement = document.createElement('audio');
this.bellAudioElement.setAttribute('preload', 'auto');
this.bellAudioElement.setAttribute('src', this.options.bellSound);
@@ -2304,12 +2306,6 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
this.helperContainer.removeChild(this.bellAudioElement);
}
}
private syncBellSound(): void {
if (this.soundBell() && this.bellAudioElement) {
this.bellAudioElement.setAttribute('src', this.options.bellSound);
}
}
}
/**