Skip to content

Commit 18a6a88

Browse files
committed
debt - remove some deprecated CSS method usages (microsoft#103454)
1 parent 9097605 commit 18a6a88

13 files changed

Lines changed: 101 additions & 117 deletions

File tree

‎src/vs/base/browser/ui/progressbar/progressbar.ts‎

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,14 @@ import 'vs/css!./progressbar';
77
import { Disposable } from 'vs/base/common/lifecycle';
88
import { Color } from 'vs/base/common/color';
99
import { mixin } from 'vs/base/common/objects';
10-
import { removeClasses, addClass, hasClass, addClasses, removeClass, hide, show } from 'vs/base/browser/dom';
10+
import { hide, show } from 'vs/base/browser/dom';
1111
import { RunOnceScheduler } from 'vs/base/common/async';
1212
import { isNumber } from 'vs/base/common/types';
1313

14-
const css_done = 'done';
15-
const css_active = 'active';
16-
const css_infinite = 'infinite';
17-
const css_discrete = 'discrete';
18-
const css_progress_container = 'monaco-progress-container';
19-
const css_progress_bit = 'progress-bit';
14+
const CSS_DONE = 'done';
15+
const CSS_ACTIVE = 'active';
16+
const CSS_INFINITE = 'infinite';
17+
const CSS_DISCRETE = 'discrete';
2018

2119
export interface IProgressBarOptions extends IProgressBarStyles {
2220
}
@@ -58,11 +56,11 @@ export class ProgressBar extends Disposable {
5856

5957
private create(container: HTMLElement): void {
6058
this.element = document.createElement('div');
61-
addClass(this.element, css_progress_container);
59+
this.element.classList.add('monaco-progress-container');
6260
container.appendChild(this.element);
6361

6462
this.bit = document.createElement('div');
65-
addClass(this.bit, css_progress_bit);
63+
this.bit.classList.add('progress-bit');
6664
this.element.appendChild(this.bit);
6765

6866
this.applyStyles();
@@ -71,7 +69,7 @@ export class ProgressBar extends Disposable {
7169
private off(): void {
7270
this.bit.style.width = 'inherit';
7371
this.bit.style.opacity = '1';
74-
removeClasses(this.element, css_active, css_infinite, css_discrete);
72+
this.element.classList.remove(CSS_ACTIVE, CSS_INFINITE, CSS_DISCRETE);
7573

7674
this.workedVal = 0;
7775
this.totalWork = undefined;
@@ -92,10 +90,10 @@ export class ProgressBar extends Disposable {
9290
}
9391

9492
private doDone(delayed: boolean): ProgressBar {
95-
addClass(this.element, css_done);
93+
this.element.classList.add(CSS_DONE);
9694

9795
// let it grow to 100% width and hide afterwards
98-
if (!hasClass(this.element, css_infinite)) {
96+
if (!this.element.classList.contains(CSS_INFINITE)) {
9997
this.bit.style.width = 'inherit';
10098

10199
if (delayed) {
@@ -125,8 +123,8 @@ export class ProgressBar extends Disposable {
125123
this.bit.style.width = '2%';
126124
this.bit.style.opacity = '1';
127125

128-
removeClasses(this.element, css_discrete, css_done);
129-
addClasses(this.element, css_active, css_infinite);
126+
this.element.classList.remove(CSS_DISCRETE, CSS_DONE);
127+
this.element.classList.add(CSS_ACTIVE, CSS_INFINITE);
130128

131129
return this;
132130
}
@@ -173,21 +171,8 @@ export class ProgressBar extends Disposable {
173171
this.workedVal = value;
174172
this.workedVal = Math.min(totalWork, this.workedVal);
175173

176-
if (hasClass(this.element, css_infinite)) {
177-
removeClass(this.element, css_infinite);
178-
}
179-
180-
if (hasClass(this.element, css_done)) {
181-
removeClass(this.element, css_done);
182-
}
183-
184-
if (!hasClass(this.element, css_active)) {
185-
addClass(this.element, css_active);
186-
}
187-
188-
if (!hasClass(this.element, css_discrete)) {
189-
addClass(this.element, css_discrete);
190-
}
174+
this.element.classList.remove(CSS_INFINITE, CSS_DONE);
175+
this.element.classList.add(CSS_ACTIVE, CSS_DISCRETE);
191176

192177
this.bit.style.width = 100 * (this.workedVal / (totalWork)) + '%';
193178

‎src/vs/workbench/browser/parts/editor/editorControl.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
77
import { EditorInput, EditorOptions, IEditorOpenContext, IVisibleEditorPane } from 'vs/workbench/common/editor';
8-
import { Dimension, show, hide, addClass } from 'vs/base/browser/dom';
8+
import { Dimension, show, hide } from 'vs/base/browser/dom';
99
import { Registry } from 'vs/platform/registry/common/platform';
1010
import { IEditorRegistry, Extensions as EditorExtensions, IEditorDescriptor } from 'vs/workbench/browser/editor';
1111
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
@@ -107,7 +107,7 @@ export class EditorControl extends Disposable {
107107
// Create editor container as needed
108108
if (!editorPane.getContainer()) {
109109
const editorPaneContainer = document.createElement('div');
110-
addClass(editorPaneContainer, 'editor-instance');
110+
editorPaneContainer.classList.add('editor-instance');
111111
editorPaneContainer.setAttribute('data-editor-id', descriptor.getId());
112112

113113
editorPane.create(editorPaneContainer);

‎src/vs/workbench/browser/parts/editor/editorDropTarget.ts‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import 'vs/css!./media/editordroptarget';
77
import { LocalSelectionTransfer, DraggedEditorIdentifier, ResourcesDropHandler, DraggedEditorGroupIdentifier, DragAndDropObserver, containsDragType } from 'vs/workbench/browser/dnd';
8-
import { addDisposableListener, EventType, EventHelper, isAncestor, toggleClass, addClass, removeClass } from 'vs/base/browser/dom';
8+
import { addDisposableListener, EventType, EventHelper, isAncestor } from 'vs/base/browser/dom';
99
import { IEditorGroupsAccessor, EDITOR_TITLE_HEIGHT, IEditorGroupView, getActiveTextEditorOptions } from 'vs/workbench/browser/parts/editor/editor';
1010
import { EDITOR_DRAG_AND_DROP_BACKGROUND } from 'vs/workbench/common/theme';
1111
import { IThemeService, Themable } from 'vs/platform/theme/common/themeService';
@@ -77,15 +77,15 @@ class DropOverlay extends Themable {
7777

7878
// Parent
7979
this.groupView.element.appendChild(container);
80-
addClass(this.groupView.element, 'dragged-over');
80+
this.groupView.element.classList.add('dragged-over');
8181
this._register(toDisposable(() => {
8282
this.groupView.element.removeChild(container);
83-
removeClass(this.groupView.element, 'dragged-over');
83+
this.groupView.element.classList.remove('dragged-over');
8484
}));
8585

8686
// Overlay
8787
this.overlay = document.createElement('div');
88-
addClass(this.overlay, 'editor-group-overlay-indicator');
88+
this.overlay.classList.add('editor-group-overlay-indicator');
8989
container.appendChild(this.overlay);
9090

9191
// Overlay Event Handling
@@ -475,7 +475,7 @@ class DropOverlay extends Themable {
475475
overlay.style.opacity = '1';
476476

477477
// Enable transition after a timeout to prevent initial animation
478-
setTimeout(() => addClass(overlay, 'overlay-move-transition'), 0);
478+
setTimeout(() => overlay.classList.add('overlay-move-transition'), 0);
479479

480480
// Remember as current split direction
481481
this.currentDropOperation = { splitDirection };
@@ -513,7 +513,7 @@ class DropOverlay extends Themable {
513513
// Reset overlay
514514
this.doPositionOverlay({ top: '0', left: '0', width: '100%', height: '100%' });
515515
overlay.style.opacity = '0';
516-
removeClass(overlay, 'overlay-move-transition');
516+
overlay.classList.remove('overlay-move-transition');
517517

518518
// Reset current operation
519519
this.currentDropOperation = undefined;
@@ -629,7 +629,7 @@ export class EditorDropTarget extends Themable {
629629
}
630630

631631
private updateContainer(isDraggedOver: boolean): void {
632-
toggleClass(this.container, 'dragged-over', isDraggedOver);
632+
this.container.classList.toggle('dragged-over', isDraggedOver);
633633
}
634634

635635
dispose(): void {

‎src/vs/workbench/browser/parts/editor/editorGroupView.ts‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { EditorGroup, IEditorOpenOptions, EditorCloseEvent, ISerializedEditorGro
88
import { EditorInput, EditorOptions, GroupIdentifier, SideBySideEditorInput, CloseDirection, IEditorCloseEvent, ActiveEditorDirtyContext, IEditorPane, EditorGroupEditorsCountContext, SaveReason, IEditorPartOptionsChangeEvent, EditorsOrder, IVisibleEditorPane, ActiveEditorStickyContext, ActiveEditorPinnedContext, Deprecated_EditorPinnedContext, Deprecated_EditorDirtyContext } from 'vs/workbench/common/editor';
99
import { Event, Emitter, Relay } from 'vs/base/common/event';
1010
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
11-
import { addClass, addClasses, Dimension, trackFocus, toggleClass, removeClass, addDisposableListener, EventType, EventHelper, findParentWithClass, clearNode, isAncestor } from 'vs/base/browser/dom';
11+
import { Dimension, trackFocus, addDisposableListener, EventType, EventHelper, findParentWithClass, clearNode, isAncestor } from 'vs/base/browser/dom';
1212
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
1313
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
1414
import { ProgressBar } from 'vs/base/browser/ui/progressbar/progressbar';
@@ -150,7 +150,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
150150
//#region create()
151151
{
152152
// Container
153-
addClasses(this.element, 'editor-group-container');
153+
this.element.classList.add('editor-group-container');
154154

155155
// Container listeners
156156
this.registerContainerListeners();
@@ -163,7 +163,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
163163

164164
// Letterpress container
165165
const letterpressContainer = document.createElement('div');
166-
addClass(letterpressContainer, 'editor-group-letterpress');
166+
letterpressContainer.classList.add('editor-group-letterpress');
167167
this.element.appendChild(letterpressContainer);
168168

169169
// Progress bar
@@ -183,15 +183,15 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
183183

184184
// Title container
185185
this.titleContainer = document.createElement('div');
186-
addClass(this.titleContainer, 'title');
186+
this.titleContainer.classList.add('title');
187187
this.element.appendChild(this.titleContainer);
188188

189189
// Title control
190190
this.titleAreaControl = this.createTitleAreaControl();
191191

192192
// Editor container
193193
this.editorContainer = document.createElement('div');
194-
addClass(this.editorContainer, 'editor-container');
194+
this.editorContainer.classList.add('editor-container');
195195
this.element.appendChild(this.editorContainer);
196196

197197
// Editor control
@@ -296,7 +296,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
296296

297297
// Toolbar Container
298298
const toolbarContainer = document.createElement('div');
299-
addClass(toolbarContainer, 'editor-group-container-toolbar');
299+
toolbarContainer.classList.add('editor-group-container-toolbar');
300300
this.element.appendChild(toolbarContainer);
301301

302302
// Toolbar
@@ -403,14 +403,14 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
403403

404404
// Empty Container: add some empty container attributes
405405
if (this.isEmpty) {
406-
addClass(this.element, 'empty');
406+
this.element.classList.add('empty');
407407
this.element.tabIndex = 0;
408408
this.element.setAttribute('aria-label', localize('emptyEditorGroup', "{0} (empty)", this.label));
409409
}
410410

411411
// Non-Empty Container: revert empty container attributes
412412
else {
413-
removeClass(this.element, 'empty');
413+
this.element.classList.remove('empty');
414414
this.element.removeAttribute('tabIndex');
415415
this.element.removeAttribute('aria-label');
416416
}
@@ -420,8 +420,8 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
420420
}
421421

422422
private updateTitleContainer(): void {
423-
toggleClass(this.titleContainer, 'tabs', this.accessor.partOptions.showTabs);
424-
toggleClass(this.titleContainer, 'show-file-icons', this.accessor.partOptions.showIcons);
423+
this.titleContainer.classList.toggle('tabs', this.accessor.partOptions.showTabs);
424+
this.titleContainer.classList.toggle('show-file-icons', this.accessor.partOptions.showIcons);
425425
}
426426

427427
private createTitleAreaControl(): TitleControl {
@@ -731,8 +731,8 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
731731
this.active = isActive;
732732

733733
// Update container
734-
toggleClass(this.element, 'active', isActive);
735-
toggleClass(this.element, 'inactive', !isActive);
734+
this.element.classList.toggle('active', isActive);
735+
this.element.classList.toggle('inactive', !isActive);
736736

737737
// Update title control
738738
this.titleAreaControl.setActive(isActive);
@@ -1662,10 +1662,10 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
16621662
// Title control
16631663
const borderColor = this.getColor(EDITOR_GROUP_HEADER_BORDER) || this.getColor(contrastBorder);
16641664
if (!isEmpty && borderColor) {
1665-
addClass(this.titleContainer, 'title-border-bottom');
1665+
this.titleContainer.classList.add('title-border-bottom');
16661666
this.titleContainer.style.setProperty('--title-border-bottom-color', borderColor.toString());
16671667
} else {
1668-
removeClass(this.titleContainer, 'title-border-bottom');
1668+
this.titleContainer.classList.remove('title-border-bottom');
16691669
this.titleContainer.style.removeProperty('--title-border-bottom-color');
16701670
}
16711671

‎src/vs/workbench/browser/parts/editor/editorPart.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import 'vs/workbench/browser/parts/editor/editor.contribution';
77
import { IThemeService } from 'vs/platform/theme/common/themeService';
88
import { Part } from 'vs/workbench/browser/part';
9-
import { Dimension, isAncestor, toggleClass, addClass, $, EventHelper, addDisposableGenericMouseDownListner } from 'vs/base/browser/dom';
9+
import { Dimension, isAncestor, $, EventHelper, addDisposableGenericMouseDownListner } from 'vs/base/browser/dom';
1010
import { Event, Emitter, Relay } from 'vs/base/common/event';
1111
import { contrastBorder, editorBackground } from 'vs/platform/theme/common/colorRegistry';
1212
import { GroupDirection, IAddGroupOptions, GroupsArrangement, GroupOrientation, IMergeGroupOptions, MergeGroupMode, GroupsOrder, GroupChangeKind, GroupLocation, IFindGroupScope, EditorGroupLayout, GroupLayoutArgument, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
@@ -820,7 +820,7 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
820820
// Container
821821
this.element = parent;
822822
this.container = document.createElement('div');
823-
addClass(this.container, 'content');
823+
this.container.classList.add('content');
824824
parent.appendChild(this.container);
825825

826826
// Grid control with center layout
@@ -833,20 +833,20 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
833833

834834
// No drop in the editor
835835
const overlay = document.createElement('div');
836-
addClass(overlay, 'drop-block-overlay');
836+
overlay.classList.add('drop-block-overlay');
837837
parent.appendChild(overlay);
838838

839839
// Hide the block if a mouse down event occurs #99065
840-
this._register(addDisposableGenericMouseDownListner(overlay, e => {
841-
toggleClass(overlay, 'visible', false);
840+
this._register(addDisposableGenericMouseDownListner(overlay, () => {
841+
overlay.classList.remove('visible');
842842
}));
843843

844844
this._register(CompositeDragAndDropObserver.INSTANCE.registerTarget(this.element, {
845845
onDragStart: e => {
846-
toggleClass(overlay, 'visible', true);
846+
overlay.classList.add('visible');
847847
},
848848
onDragEnd: e => {
849-
toggleClass(overlay, 'visible', false);
849+
overlay.classList.remove('visible');
850850
}
851851
}));
852852

@@ -1053,7 +1053,7 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
10531053

10541054
private updateContainer(): void {
10551055
const container = assertIsDefined(this.container);
1056-
toggleClass(container, 'empty', this.isEmpty);
1056+
container.classList.toggle('empty', this.isEmpty);
10571057
}
10581058

10591059
private notifyGroupIndexChange(): void {

0 commit comments

Comments
 (0)