Fix strictNullChecks errors in AccessibilityManager

Part of #1319
This commit is contained in:
Daniel Imms
2018-03-09 11:27:10 -08:00
parent 90b2f0e6a1
commit 4f0cc01485
+9 -12
View File
@@ -20,7 +20,7 @@ enum BoundaryPosition {
export class AccessibilityManager implements IDisposable { export class AccessibilityManager implements IDisposable {
private _accessibilityTreeRoot: HTMLElement; private _accessibilityTreeRoot: HTMLElement;
private _rowContainer: HTMLElement; private _rowContainer: HTMLElement;
private _rowElements: HTMLElement[] = []; private _rowElements: HTMLElement[];
private _liveRegion: HTMLElement; private _liveRegion: HTMLElement;
private _liveRegionLineCount: number = 0; private _liveRegionLineCount: number = 0;
@@ -48,6 +48,7 @@ export class AccessibilityManager implements IDisposable {
this._rowContainer = document.createElement('div'); this._rowContainer = document.createElement('div');
this._rowContainer.classList.add('xterm-accessibility-tree'); this._rowContainer.classList.add('xterm-accessibility-tree');
this._rowElements = [];
for (let i = 0; i < this._terminal.rows; i++) { for (let i = 0; i < this._terminal.rows; i++) {
this._rowElements[i] = this._createAccessibilityTreeNode(); this._rowElements[i] = this._createAccessibilityTreeNode();
this._rowContainer.appendChild(this._rowElements[i]); this._rowContainer.appendChild(this._rowElements[i]);
@@ -92,14 +93,10 @@ export class AccessibilityManager implements IDisposable {
} }
public dispose(): void { public dispose(): void {
this._terminal.element.removeChild(this._accessibilityTreeRoot);
this._disposables.forEach(d => d.dispose()); this._disposables.forEach(d => d.dispose());
this._disposables = null; this._disposables.length = 0;
this._accessibilityTreeRoot = null; this._terminal.element.removeChild(this._accessibilityTreeRoot);
this._rowContainer = null; this._rowElements.length = 0;
this._liveRegion = null;
this._rowContainer = null;
this._rowElements = null;
} }
private _onBoundaryFocus(e: FocusEvent, position: BoundaryPosition): void { private _onBoundaryFocus(e: FocusEvent, position: BoundaryPosition): void {
@@ -124,10 +121,10 @@ export class AccessibilityManager implements IDisposable {
let bottomBoundaryElement: HTMLElement; let bottomBoundaryElement: HTMLElement;
if (position === BoundaryPosition.Top) { if (position === BoundaryPosition.Top) {
topBoundaryElement = boundaryElement; topBoundaryElement = boundaryElement;
bottomBoundaryElement = this._rowElements.pop(); bottomBoundaryElement = <HTMLElement>this._rowElements.pop();
this._rowContainer.removeChild(bottomBoundaryElement); this._rowContainer.removeChild(bottomBoundaryElement);
} else { } else {
topBoundaryElement = this._rowElements.shift(); topBoundaryElement = <HTMLElement>this._rowElements.shift();
bottomBoundaryElement = boundaryElement; bottomBoundaryElement = boundaryElement;
this._rowContainer.removeChild(topBoundaryElement); this._rowContainer.removeChild(topBoundaryElement);
} }
@@ -173,7 +170,7 @@ export class AccessibilityManager implements IDisposable {
} }
// Shrink rows as required // Shrink rows as required
while (this._rowElements.length > rows) { while (this._rowElements.length > rows) {
this._rowContainer.removeChild(this._rowElements.pop()); this._rowContainer.removeChild(<HTMLElement>this._rowElements.pop());
} }
// Add bottom boundary listener // Add bottom boundary listener
@@ -217,7 +214,7 @@ export class AccessibilityManager implements IDisposable {
// Only detach/attach on mac as otherwise messages can go unaccounced // Only detach/attach on mac as otherwise messages can go unaccounced
if (isMac) { if (isMac) {
if (this._liveRegion.textContent.length > 0 && !this._liveRegion.parentNode) { if (this._liveRegion.textContent && this._liveRegion.textContent.length > 0 && !this._liveRegion.parentNode) {
setTimeout(() => { setTimeout(() => {
this._accessibilityTreeRoot.appendChild(this._liveRegion); this._accessibilityTreeRoot.appendChild(this._liveRegion);
}, 0); }, 0);