Skip to content

Commit

Permalink
Merge pull request #4364 from Tyriar/dom_remove
Browse files Browse the repository at this point in the history
Replace dom helper with HTMLElement.remove()
  • Loading branch information
Tyriar authored Jan 5, 2023
2 parents 91946dc + b3fb8db commit ba9f2e0
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 59 deletions.
3 changes: 1 addition & 2 deletions addons/xterm-addon-canvas/src/BaseRenderLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* @license MIT
*/

import { removeElementFromParent } from 'browser/Dom';
import { acquireTextureAtlas } from 'browser/renderer/shared/CharAtlasCache';
import { TEXT_BASELINE } from 'browser/renderer/shared/Constants';
import { tryDrawCustomChar } from 'browser/renderer/shared/CustomGlyphs';
Expand Down Expand Up @@ -74,7 +73,7 @@ export abstract class BaseRenderLayer extends Disposable implements IRenderLayer
}));

this.register(toDisposable(() => {
removeElementFromParent(this._canvas);
this._canvas.remove();
this._charAtlas?.dispose();
}));
}
Expand Down
5 changes: 2 additions & 3 deletions src/browser/AccessibilityManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { addDisposableDomListener } from 'browser/Lifecycle';
import { Disposable, toDisposable } from 'common/Lifecycle';
import { ScreenDprMonitor } from 'browser/ScreenDprMonitor';
import { IRenderService } from 'browser/services/Services';
import { removeElementFromParent } from 'browser/Dom';

const MAX_ROWS_TO_READ = 20;

Expand Down Expand Up @@ -105,7 +104,7 @@ export class AccessibilityManager extends Disposable {
// media query that drives the ScreenDprMonitor isn't supported
this.register(addDisposableDomListener(window, 'resize', () => this._refreshRowsDimensions()));
this.register(toDisposable(() => {
removeElementFromParent(this._accessibilityTreeRoot);
this._accessibilityTreeRoot.remove();
this._rowElements.length = 0;
}));
}
Expand Down Expand Up @@ -240,7 +239,7 @@ export class AccessibilityManager extends Disposable {

// Only detach/attach on mac as otherwise messages can go unaccounced
if (isMac) {
removeElementFromParent(this._liveRegion);
this._liveRegion.remove();
}
}

Expand Down
41 changes: 0 additions & 41 deletions src/browser/Dom.test.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/browser/Dom.ts

This file was deleted.

6 changes: 4 additions & 2 deletions src/browser/renderer/dom/DomRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* @license MIT
*/

import { removeElementFromParent } from 'browser/Dom';
import { BOLD_CLASS, CURSOR_BLINK_CLASS, CURSOR_CLASS, CURSOR_STYLE_BAR_CLASS, CURSOR_STYLE_BLOCK_CLASS, CURSOR_STYLE_UNDERLINE_CLASS, DomRendererRowFactory, ITALIC_CLASS } from 'browser/renderer/dom/DomRendererRowFactory';
import { INVERTED_DEFAULT_COLOR } from 'browser/renderer/shared/Constants';
import { createRenderDimensions } from 'browser/renderer/shared/RendererUtils';
Expand Down Expand Up @@ -87,7 +86,10 @@ export class DomRenderer extends Disposable implements IRenderer {

// Outside influences such as React unmounts may manipulate the DOM before our disposal.
// https://github.com/xtermjs/xterm.js/issues/2960
removeElementFromParent(this._rowContainer, this._selectionContainer, this._themeStyleElement, this._dimensionsStyleElement);
this._rowContainer.remove();
this._selectionContainer.remove();
this._themeStyleElement.remove();
this._dimensionsStyleElement.remove();
}));
}

Expand Down
2 changes: 1 addition & 1 deletion typings/xterm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@ declare module 'xterm' {
* @param range The buffer range of the link.
*/
leave?(event: MouseEvent, text: string, range: IBufferRange): void;

/**
* Whether to receive non-HTTP URLs from LinkProvider. When false, any usage of non-HTTP URLs
* will be ignored. Enabling this option without proper protection in `activate` function
Expand Down

0 comments on commit ba9f2e0

Please sign in to comment.