From 4b9c60bb9a511d9080adfa8a8cd91839616c0ae2 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Tue, 22 Sep 2020 12:53:21 +0200 Subject: [PATCH] Remove some deprecated code in ./src/vs/base #103454 --- .../comments/browser/commentThreadWidget.ts | 14 +++++--------- .../notebook/browser/contrib/fold/folding.ts | 5 ++--- .../notebook/browser/diff/cellComponents.ts | 4 ++-- .../notebook/browser/notebookEditorWidget.ts | 6 +++--- .../contrib/preferences/browser/settingsEditor2.ts | 2 +- .../workbench/contrib/search/browser/searchView.ts | 8 ++++---- .../contrib/search/browser/searchWidget.ts | 2 +- .../contrib/searchEditor/browser/searchEditor.ts | 8 ++++---- .../contrib/terminal/browser/terminalInstance.ts | 2 +- 9 files changed, 23 insertions(+), 28 deletions(-) diff --git a/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts b/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts index 4f38a52fe06..d9403b06d8c 100644 --- a/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts +++ b/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts @@ -550,9 +550,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget if (input.value === '') { this._pendingComment = ''; - if (dom.hasClass(this._commentForm, 'expand')) { - dom.removeClass(this._commentForm, 'expand'); - } + this._commentForm.classList.remove('expand'); this._commentEditor.getDomNode()!.style.outline = ''; this._error.textContent = ''; dom.addClass(this._error, 'hidden'); @@ -698,8 +696,8 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget } private expandReplyArea() { - if (!dom.hasClass(this._commentForm, 'expand')) { - dom.addClass(this._commentForm, 'expand'); + if (!this._commentForm.classList.contains('expand')) { + this._commentForm.classList.add('expand'); this._commentEditor.focus(); } } @@ -707,9 +705,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget private hideReplyArea() { this._commentEditor.setValue(''); this._pendingComment = ''; - if (dom.hasClass(this._commentForm, 'expand')) { - dom.removeClass(this._commentForm, 'expand'); - } + this._commentForm.classList.remove('expand'); this._commentEditor.getDomNode()!.style.outline = ''; this._error.textContent = ''; dom.addClass(this._error, 'hidden'); @@ -725,7 +721,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget this._disposables.add(dom.addDisposableListener(this._reviewThreadReplyButton, 'focus', _ => this.expandReplyArea())); this._commentEditor.onDidBlurEditorWidget(() => { - if (this._commentEditor.getModel()!.getValueLength() === 0 && dom.hasClass(this._commentForm, 'expand')) { + if (this._commentEditor.getModel()!.getValueLength() === 0 && this._commentForm.classList.add('expand')) { dom.removeClass(this._commentForm, 'expand'); } }); diff --git a/src/vs/workbench/contrib/notebook/browser/contrib/fold/folding.ts b/src/vs/workbench/contrib/notebook/browser/contrib/fold/folding.ts index aa7711d6817..9be776cc108 100644 --- a/src/vs/workbench/contrib/notebook/browser/contrib/fold/folding.ts +++ b/src/vs/workbench/contrib/notebook/browser/contrib/fold/folding.ts @@ -5,7 +5,6 @@ import { Disposable, DisposableStore } from 'vs/base/common/lifecycle'; import { INotebookEditor, INotebookEditorMouseEvent, INotebookEditorContribution, NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_IS_ACTIVE_EDITOR } from 'vs/workbench/contrib/notebook/browser/notebookBrowser'; -import * as DOM from 'vs/base/browser/dom'; import { CellFoldingState, FoldingModel } from 'vs/workbench/contrib/notebook/browser/contrib/fold/foldingModel'; import { CellKind, ICellRange } from 'vs/workbench/contrib/notebook/common/notebookCommon'; import { registerNotebookContribution } from 'vs/workbench/contrib/notebook/browser/notebookEditorExtensions'; @@ -117,10 +116,10 @@ export class FoldingController extends Disposable implements INotebookEditorCont const target = e.event.target as HTMLElement; - if (DOM.hasClass(target, 'codicon-chevron-down') || DOM.hasClass(target, 'codicon-chevron-right')) { + if (target.classList.contains('codicon-chevron-down') || target.classList.contains('codicon-chevron-right')) { const parent = target.parentElement as HTMLElement; - if (!DOM.hasClass(parent, 'notebook-folding-indicator')) { + if (!parent.classList.contains('notebook-folding-indicator')) { return; } diff --git a/src/vs/workbench/contrib/notebook/browser/diff/cellComponents.ts b/src/vs/workbench/contrib/notebook/browser/diff/cellComponents.ts index 4366a462dfe..2325a7ae11e 100644 --- a/src/vs/workbench/contrib/notebook/browser/diff/cellComponents.ts +++ b/src/vs/workbench/contrib/notebook/browser/diff/cellComponents.ts @@ -142,7 +142,7 @@ class PropertyHeader extends Disposable { const target = e.event.target as HTMLElement; - if (DOM.hasClass(target, 'codicon-chevron-down') || DOM.hasClass(target, 'codicon-chevron-right')) { + if (target.classList.contains('codicon-chevron-down') || target.classList.contains('codicon-chevron-right')) { const parent = target.parentElement as HTMLElement; if (!parent) { @@ -153,7 +153,7 @@ class PropertyHeader extends Disposable { return; } - if (!DOM.hasClass(parent, 'property-folding-indicator')) { + if (!parent.classList.contains('property-folding-indicator')) { return; } diff --git a/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts b/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts index 992aa34a3e8..5fdb4c30007 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts @@ -371,7 +371,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor && container !== this._body) { - if (DOM.hasClass(container as HTMLElement, 'output')) { + if ((container as HTMLElement).classList.contains('output')) { return true; } @@ -385,7 +385,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor const id = generateUuid(); this._overlayContainer.id = `notebook-${id}`; this._overlayContainer.className = 'notebookOverlay'; - DOM.addClass(this._overlayContainer, 'notebook-editor'); + this._overlayContainer.classList.add('notebook-editor'); this._overlayContainer.style.visibility = 'hidden'; this.layoutService.container.appendChild(this._overlayContainer); @@ -512,7 +512,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor this._webviewTransparentCover.style.display = 'none'; this._register(DOM.addStandardDisposableGenericMouseDownListner(this._overlayContainer, (e: StandardMouseEvent) => { - if (DOM.hasClass(e.target, 'slider') && this._webviewTransparentCover) { + if (e.target.classList.contains('slider') && this._webviewTransparentCover) { this._webviewTransparentCover.style.display = 'block'; } })); diff --git a/src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts b/src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts index 7892c7c160f..47b1ed96b1b 100644 --- a/src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts +++ b/src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts @@ -1041,7 +1041,7 @@ export class SettingsEditor2 extends EditorPane { const focusedKey = focusedSetting.getAttribute(AbstractSettingRenderer.SETTING_KEY_ATTR); if (focusedKey === key && // update `list`s live, as they have a separate "submit edit" step built in before this - (focusedSetting.parentElement && !DOM.hasClass(focusedSetting.parentElement, 'setting-item-list')) + (focusedSetting.parentElement && !focusedSetting.parentElement.classList.contains('setting-item-list')) ) { this.updateModifiedLabelForKey(key); diff --git a/src/vs/workbench/contrib/search/browser/searchView.ts b/src/vs/workbench/contrib/search/browser/searchView.ts index 7f50bf10765..2a53fe46356 100644 --- a/src/vs/workbench/contrib/search/browser/searchView.ts +++ b/src/vs/workbench/contrib/search/browser/searchView.ts @@ -1142,7 +1142,7 @@ export class SearchView extends ViewPane { } private showsFileTypes(): boolean { - return dom.hasClass(this.queryDetails, 'more'); + return this.queryDetails.classList.contains('more'); } toggleCaseSensitive(): void { @@ -1193,13 +1193,13 @@ export class SearchView extends ViewPane { toggleQueryDetails(moveFocus = true, show?: boolean, skipLayout?: boolean, reverse?: boolean): void { const cls = 'more'; - show = typeof show === 'undefined' ? !dom.hasClass(this.queryDetails, cls) : Boolean(show); + show = typeof show === 'undefined' ? !this.queryDetails.classList.contains(cls) : Boolean(show); this.viewletState['query.queryDetailsExpanded'] = show; skipLayout = Boolean(skipLayout); if (show) { this.toggleQueryDetailsButton.setAttribute('aria-expanded', 'true'); - dom.addClass(this.queryDetails, cls); + this.queryDetails.classList.add(cls); if (moveFocus) { if (reverse) { this.inputPatternExcludes.focus(); @@ -1211,7 +1211,7 @@ export class SearchView extends ViewPane { } } else { this.toggleQueryDetailsButton.setAttribute('aria-expanded', 'false'); - dom.removeClass(this.queryDetails, cls); + this.queryDetails.classList.remove(cls); if (moveFocus) { this.searchWidget.focus(); } diff --git a/src/vs/workbench/contrib/search/browser/searchWidget.ts b/src/vs/workbench/contrib/search/browser/searchWidget.ts index 34b1786dd61..78d6587b423 100644 --- a/src/vs/workbench/contrib/search/browser/searchWidget.ts +++ b/src/vs/workbench/contrib/search/browser/searchWidget.ts @@ -207,7 +207,7 @@ export class SearchWidget extends Widget { } isReplaceShown(): boolean { - return !dom.hasClass(this.replaceContainer, 'disabled'); + return !this.replaceContainer.classList.contains('disabled'); } isReplaceActive(): boolean { diff --git a/src/vs/workbench/contrib/searchEditor/browser/searchEditor.ts b/src/vs/workbench/contrib/searchEditor/browser/searchEditor.ts index 4c1c7205324..d9e9cc9c953 100644 --- a/src/vs/workbench/contrib/searchEditor/browser/searchEditor.ts +++ b/src/vs/workbench/contrib/searchEditor/browser/searchEditor.ts @@ -591,17 +591,17 @@ export class SearchEditor extends BaseTextEditor { private toggleIncludesExcludes(_shouldShow?: boolean): void { const cls = 'expanded'; - const shouldShow = _shouldShow ?? !DOM.hasClass(this.includesExcludesContainer, cls); + const shouldShow = _shouldShow ?? !this.includesExcludesContainer.classList.contains(cls); if (shouldShow) { this.toggleQueryDetailsButton.setAttribute('aria-expanded', 'true'); - DOM.addClass(this.includesExcludesContainer, cls); + this.includesExcludesContainer.classList.add(cls); } else { this.toggleQueryDetailsButton.setAttribute('aria-expanded', 'false'); - DOM.removeClass(this.includesExcludesContainer, cls); + this.includesExcludesContainer.classList.remove(cls); } - this.showingIncludesExcludes = DOM.hasClass(this.includesExcludesContainer, cls); + this.showingIncludesExcludes = this.includesExcludesContainer.classList.contains(cls); this.reLayout(); } diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index 76de543e187..c2a2e9a1721 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -730,7 +730,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { dispose(this._widgetManager); if (this._xterm && this._xterm.element) { - this._hadFocusOnExit = dom.hasClass(this._xterm.element, 'focus'); + this._hadFocusOnExit = this._xterm.element.classList.contains('focus'); } if (this._wrapperElement) { if (this._wrapperElement.xterm) {