Skip to content

Commit fc8805d

Browse files
committed
Adopt new APIs (for microsoft#103454)
1 parent 953d32c commit fc8805d

10 files changed

Lines changed: 32 additions & 36 deletions

File tree

src/vs/base/browser/fastDomNode.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import * as dom from 'vs/base/browser/dom';
7-
86
export class FastDomNode<T extends HTMLElement> {
97

108
public readonly domNode: T;
@@ -176,7 +174,7 @@ export class FastDomNode<T extends HTMLElement> {
176174
}
177175

178176
public toggleClassName(className: string, shouldHaveIt?: boolean): void {
179-
dom.toggleClass(this.domNode, className, shouldHaveIt);
177+
this.domNode.classList.toggle(className, shouldHaveIt);
180178
this._className = this.domNode.className;
181179
}
182180

src/vs/base/browser/ui/findinput/findInput.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export class FindInput extends Widget {
128128
const flexibleMaxHeight = options.flexibleMaxHeight;
129129

130130
this.domNode = document.createElement('div');
131-
dom.addClass(this.domNode, 'monaco-findInput');
131+
this.domNode.classList.add('monaco-findInput');
132132

133133
this.inputBox = this._register(new HistoryInputBox(this.domNode, this.contextViewProvider, {
134134
placeholder: this.placeholder || '',
@@ -258,15 +258,15 @@ export class FindInput extends Widget {
258258
}
259259

260260
public enable(): void {
261-
dom.removeClass(this.domNode, 'disabled');
261+
this.domNode.classList.remove('disabled');
262262
this.inputBox.enable();
263263
this.regex.enable();
264264
this.wholeWords.enable();
265265
this.caseSensitive.enable();
266266
}
267267

268268
public disable(): void {
269-
dom.addClass(this.domNode, 'disabled');
269+
this.domNode.classList.add('disabled');
270270
this.inputBox.disable();
271271
this.regex.disable();
272272
this.wholeWords.disable();
@@ -398,9 +398,9 @@ export class FindInput extends Widget {
398398

399399
private _lastHighlightFindOptions: number = 0;
400400
public highlightFindOptions(): void {
401-
dom.removeClass(this.domNode, 'highlight-' + (this._lastHighlightFindOptions));
401+
this.domNode.classList.remove('highlight-' + (this._lastHighlightFindOptions));
402402
this._lastHighlightFindOptions = 1 - this._lastHighlightFindOptions;
403-
dom.addClass(this.domNode, 'highlight-' + (this._lastHighlightFindOptions));
403+
this.domNode.classList.add('highlight-' + (this._lastHighlightFindOptions));
404404
}
405405

406406
public validate(): void {

src/vs/base/browser/ui/findinput/replaceInput.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export class ReplaceInput extends Widget {
134134
const flexibleMaxHeight = options.flexibleMaxHeight;
135135

136136
this.domNode = document.createElement('div');
137-
dom.addClass(this.domNode, 'monaco-findInput');
137+
this.domNode.classList.add('monaco-findInput');
138138

139139
this.inputBox = this._register(new HistoryInputBox(this.domNode, this.contextViewProvider, {
140140
ariaLabel: this.label || '',
@@ -231,13 +231,13 @@ export class ReplaceInput extends Widget {
231231
}
232232

233233
public enable(): void {
234-
dom.removeClass(this.domNode, 'disabled');
234+
this.domNode.classList.remove('disabled');
235235
this.inputBox.enable();
236236
this.preserveCase.enable();
237237
}
238238

239239
public disable(): void {
240-
dom.addClass(this.domNode, 'disabled');
240+
this.domNode.classList.add('disabled');
241241
this.inputBox.disable();
242242
this.preserveCase.disable();
243243
}
@@ -344,9 +344,9 @@ export class ReplaceInput extends Widget {
344344

345345
private _lastHighlightFindOptions: number = 0;
346346
public highlightFindOptions(): void {
347-
dom.removeClass(this.domNode, 'highlight-' + (this._lastHighlightFindOptions));
347+
this.domNode.classList.remove('highlight-' + (this._lastHighlightFindOptions));
348348
this._lastHighlightFindOptions = 1 - this._lastHighlightFindOptions;
349-
dom.addClass(this.domNode, 'highlight-' + (this._lastHighlightFindOptions));
349+
this.domNode.classList.add('highlight-' + (this._lastHighlightFindOptions));
350350
}
351351

352352
public validate(): void {

src/vs/base/parts/ipc/common/ipc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ export function logWithColors(direction: string, totalLength: number, msgLength:
11851185

11861186
const colorTable = colorTables[initiator];
11871187
const color = colorTable[req % colorTable.length];
1188-
let args = [`%c[${direction}]%c[${strings.pad(totalLength, 7, ' ')}]%c[len: ${strings.pad(msgLength, 5, ' ')}]%c${strings.pad(req, 5, ' ')} - ${str}`, 'color: darkgreen', 'color: grey', 'color: grey', `color: ${color}`];
1188+
let args = [`%c[${direction}]%c[${String(totalLength).padStart(7, ' ')}]%c[len: ${String(msgLength).padStart(5, ' ')}]%c${String(req).padStart(5, ' ')} - ${str}`, 'color: darkgreen', 'color: grey', 'color: grey', `color: ${color}`];
11891189
if (/\($/.test(str)) {
11901190
args = args.concat(data);
11911191
args.push(')');

src/vs/editor/browser/controller/textAreaState.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,13 @@ export class TextAreaState {
145145

146146
if (currentSelectionStart === currentValue.length) {
147147
// emoji potentially inserted "somewhere" after the previous selection => it should appear at the end of `currentValue`
148-
if (strings.startsWith(currentValue, previousValue)) {
148+
if (currentValue.startsWith(previousValue)) {
149149
// only if all of the old text is accounted for
150150
potentialEmojiInput = currentValue.substring(previousValue.length);
151151
}
152152
} else {
153153
// emoji potentially inserted "somewhere" before the previous selection => it should appear at the start of `currentValue`
154-
if (strings.endsWith(currentValue, previousValue)) {
154+
if (currentValue.endsWith(previousValue)) {
155155
// only if all of the old text is accounted for
156156
potentialEmojiInput = currentValue.substring(0, currentValue.length - previousValue.length);
157157
}

src/vs/editor/common/controller/cursorTypeOperations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ export class TypeOperations {
228228
let goodIndent = this._goodIndentForLine(config, model, selection.startLineNumber);
229229
goodIndent = goodIndent || '\t';
230230
let possibleTypeText = config.normalizeIndentation(goodIndent);
231-
if (!strings.startsWith(lineText, possibleTypeText)) {
231+
if (!lineText.startsWith(possibleTypeText)) {
232232
commands[i] = new ReplaceCommand(new Range(selection.startLineNumber, 1, selection.startLineNumber, lineText.length + 1), possibleTypeText, true);
233233
continue;
234234
}

src/vs/editor/contrib/find/findWidget.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
363363
}
364364
if (e.searchString || e.matchesCount || e.matchesPosition) {
365365
let showRedOutline = (this._state.searchString.length > 0 && this._state.matchesCount === 0);
366-
dom.toggleClass(this._domNode, 'no-results', showRedOutline);
366+
this._domNode.classList.toggle('no-results', showRedOutline);
367367

368368
this._updateMatchesCount();
369369
this._updateButtons();
@@ -477,7 +477,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
477477
this._replaceBtn.setEnabled(this._isVisible && this._isReplaceVisible && findInputIsNonEmpty);
478478
this._replaceAllBtn.setEnabled(this._isVisible && this._isReplaceVisible && findInputIsNonEmpty);
479479

480-
dom.toggleClass(this._domNode, 'replaceToggled', this._isReplaceVisible);
480+
this._domNode.classList.toggle('replaceToggled', this._isReplaceVisible);
481481
this._toggleReplaceBtn.setExpanded(this._isReplaceVisible);
482482

483483
let canReplace = !this._codeEditor.getOption(EditorOption.readOnly);
@@ -510,7 +510,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
510510
this._updateButtons();
511511

512512
setTimeout(() => {
513-
dom.addClass(this._domNode, 'visible');
513+
this._domNode.classList.add('visible');
514514
this._domNode.setAttribute('aria-hidden', 'false');
515515
}, 0);
516516

@@ -557,7 +557,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
557557

558558
this._updateButtons();
559559

560-
dom.removeClass(this._domNode, 'visible');
560+
this._domNode.classList.remove('visible');
561561
this._domNode.setAttribute('aria-hidden', 'true');
562562
this._findInput.clearMessage();
563563
if (focusTheEditor) {
@@ -695,10 +695,10 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
695695

696696
if (editorContentWidth <= 0) {
697697
// for example, diff view original editor
698-
dom.addClass(this._domNode, 'hiddenEditor');
698+
this._domNode.classList.add('hiddenEditor');
699699
return;
700-
} else if (dom.hasClass(this._domNode, 'hiddenEditor')) {
701-
dom.removeClass(this._domNode, 'hiddenEditor');
700+
} else if (this._domNode.classList.contains('hiddenEditor')) {
701+
this._domNode.classList.remove('hiddenEditor');
702702
}
703703

704704
const editorWidth = layoutInfo.width;
@@ -727,9 +727,9 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
727727
if (FIND_WIDGET_INITIAL_WIDTH + 28 + minimapWidth - MAX_MATCHES_COUNT_WIDTH >= editorWidth + 50) {
728728
collapsedFindWidget = true;
729729
}
730-
dom.toggleClass(this._domNode, 'collapsed-find-widget', collapsedFindWidget);
731-
dom.toggleClass(this._domNode, 'narrow-find-widget', narrowFindWidget);
732-
dom.toggleClass(this._domNode, 'reduced-find-widget', reducedFindWidget);
730+
this._domNode.classList.toggle('collapsed-find-widget', collapsedFindWidget);
731+
this._domNode.classList.toggle('narrow-find-widget', narrowFindWidget);
732+
this._domNode.classList.toggle('reduced-find-widget', reducedFindWidget);
733733

734734
if (!narrowFindWidget && !collapsedFindWidget) {
735735
// the minimal left offset of findwidget is 15px.
@@ -1306,7 +1306,7 @@ export class SimpleButton extends Widget {
13061306
}
13071307

13081308
public setEnabled(enabled: boolean): void {
1309-
dom.toggleClass(this._domNode, 'disabled', !enabled);
1309+
this._domNode.classList.toggle('disabled', !enabled);
13101310
this._domNode.setAttribute('aria-disabled', String(!enabled));
13111311
this._domNode.tabIndex = enabled ? 0 : -1;
13121312
}

src/vs/editor/contrib/hover/hoverWidgets.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import * as dom from 'vs/base/browser/dom';
76
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
87
import { Widget } from 'vs/base/browser/ui/widget';
98
import { KeyCode } from 'vs/base/common/keyCodes';
@@ -35,7 +34,7 @@ export class ContentHoverWidget extends Widget implements IContentWidget {
3534

3635
protected set isVisible(value: boolean) {
3736
this._isVisible = value;
38-
dom.toggleClass(this._hover.containerDomNode, 'hidden', !this._isVisible);
37+
this._hover.containerDomNode.classList.toggle('hidden', !this._isVisible);
3938
}
4039

4140
constructor(
@@ -203,7 +202,7 @@ export class GlyphHoverWidget extends Widget implements IOverlayWidget {
203202

204203
protected set isVisible(value: boolean) {
205204
this._isVisible = value;
206-
dom.toggleClass(this._domNode, 'hidden', !this._isVisible);
205+
this._domNode.classList.toggle('hidden', !this._isVisible);
207206
}
208207

209208
public getId(): string {

src/vs/editor/contrib/links/links.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import { EditorOption } from 'vs/editor/common/config/editorOptions';
2828
import { URI } from 'vs/base/common/uri';
2929
import { Schemas } from 'vs/base/common/network';
3030
import * as resources from 'vs/base/common/resources';
31-
import * as strings from 'vs/base/common/strings';
3231

3332
function getHoverMessage(link: Link, useMetaKey: boolean): MarkdownString {
3433
const executeCmd = link.url && /^command:/i.test(link.url.toString());
@@ -299,15 +298,15 @@ export class LinkDetector implements IEditorContribution {
299298
// Support for relative file URIs of the shape file://./relativeFile.txt or file:///./relativeFile.txt
300299
if (typeof uri === 'string' && this.editor.hasModel()) {
301300
const modelUri = this.editor.getModel().uri;
302-
if (modelUri.scheme === Schemas.file && strings.startsWith(uri, 'file:')) {
301+
if (modelUri.scheme === Schemas.file && uri.startsWith('file:')) {
303302
const parsedUri = URI.parse(uri);
304303
if (parsedUri.scheme === Schemas.file) {
305304
const fsPath = resources.originalFSPath(parsedUri);
306305

307306
let relativePath: string | null = null;
308-
if (strings.startsWith(fsPath, '/./')) {
307+
if (fsPath.startsWith('/./')) {
309308
relativePath = `.${fsPath.substr(1)}`;
310-
} else if (strings.startsWith(fsPath, '//./')) {
309+
} else if (fsPath.startsWith('//./')) {
311310
relativePath = `.${fsPath.substr(2)}`;
312311
}
313312

src/vs/editor/contrib/zoneWidget/zoneWidget.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ export abstract class ZoneWidget implements IHorizontalSashLayoutProvider {
451451
this.container.classList.remove(classToReplace);
452452
}
453453

454-
dom.addClass(this.container, className);
454+
this.container.classList.add(className);
455455

456456
}
457457

0 commit comments

Comments
 (0)