未验证 提交 fc8805df 编写于 作者: A Alex Dima

Adopt new APIs (for #103454)

上级 953d32c4
......@@ -3,8 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as dom from 'vs/base/browser/dom';
export class FastDomNode<T extends HTMLElement> {
public readonly domNode: T;
......@@ -176,7 +174,7 @@ export class FastDomNode<T extends HTMLElement> {
}
public toggleClassName(className: string, shouldHaveIt?: boolean): void {
dom.toggleClass(this.domNode, className, shouldHaveIt);
this.domNode.classList.toggle(className, shouldHaveIt);
this._className = this.domNode.className;
}
......
......@@ -128,7 +128,7 @@ export class FindInput extends Widget {
const flexibleMaxHeight = options.flexibleMaxHeight;
this.domNode = document.createElement('div');
dom.addClass(this.domNode, 'monaco-findInput');
this.domNode.classList.add('monaco-findInput');
this.inputBox = this._register(new HistoryInputBox(this.domNode, this.contextViewProvider, {
placeholder: this.placeholder || '',
......@@ -258,7 +258,7 @@ export class FindInput extends Widget {
}
public enable(): void {
dom.removeClass(this.domNode, 'disabled');
this.domNode.classList.remove('disabled');
this.inputBox.enable();
this.regex.enable();
this.wholeWords.enable();
......@@ -266,7 +266,7 @@ export class FindInput extends Widget {
}
public disable(): void {
dom.addClass(this.domNode, 'disabled');
this.domNode.classList.add('disabled');
this.inputBox.disable();
this.regex.disable();
this.wholeWords.disable();
......@@ -398,9 +398,9 @@ export class FindInput extends Widget {
private _lastHighlightFindOptions: number = 0;
public highlightFindOptions(): void {
dom.removeClass(this.domNode, 'highlight-' + (this._lastHighlightFindOptions));
this.domNode.classList.remove('highlight-' + (this._lastHighlightFindOptions));
this._lastHighlightFindOptions = 1 - this._lastHighlightFindOptions;
dom.addClass(this.domNode, 'highlight-' + (this._lastHighlightFindOptions));
this.domNode.classList.add('highlight-' + (this._lastHighlightFindOptions));
}
public validate(): void {
......
......@@ -134,7 +134,7 @@ export class ReplaceInput extends Widget {
const flexibleMaxHeight = options.flexibleMaxHeight;
this.domNode = document.createElement('div');
dom.addClass(this.domNode, 'monaco-findInput');
this.domNode.classList.add('monaco-findInput');
this.inputBox = this._register(new HistoryInputBox(this.domNode, this.contextViewProvider, {
ariaLabel: this.label || '',
......@@ -231,13 +231,13 @@ export class ReplaceInput extends Widget {
}
public enable(): void {
dom.removeClass(this.domNode, 'disabled');
this.domNode.classList.remove('disabled');
this.inputBox.enable();
this.preserveCase.enable();
}
public disable(): void {
dom.addClass(this.domNode, 'disabled');
this.domNode.classList.add('disabled');
this.inputBox.disable();
this.preserveCase.disable();
}
......@@ -344,9 +344,9 @@ export class ReplaceInput extends Widget {
private _lastHighlightFindOptions: number = 0;
public highlightFindOptions(): void {
dom.removeClass(this.domNode, 'highlight-' + (this._lastHighlightFindOptions));
this.domNode.classList.remove('highlight-' + (this._lastHighlightFindOptions));
this._lastHighlightFindOptions = 1 - this._lastHighlightFindOptions;
dom.addClass(this.domNode, 'highlight-' + (this._lastHighlightFindOptions));
this.domNode.classList.add('highlight-' + (this._lastHighlightFindOptions));
}
public validate(): void {
......
......@@ -1185,7 +1185,7 @@ export function logWithColors(direction: string, totalLength: number, msgLength:
const colorTable = colorTables[initiator];
const color = colorTable[req % colorTable.length];
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}`];
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}`];
if (/\($/.test(str)) {
args = args.concat(data);
args.push(')');
......
......@@ -145,13 +145,13 @@ export class TextAreaState {
if (currentSelectionStart === currentValue.length) {
// emoji potentially inserted "somewhere" after the previous selection => it should appear at the end of `currentValue`
if (strings.startsWith(currentValue, previousValue)) {
if (currentValue.startsWith(previousValue)) {
// only if all of the old text is accounted for
potentialEmojiInput = currentValue.substring(previousValue.length);
}
} else {
// emoji potentially inserted "somewhere" before the previous selection => it should appear at the start of `currentValue`
if (strings.endsWith(currentValue, previousValue)) {
if (currentValue.endsWith(previousValue)) {
// only if all of the old text is accounted for
potentialEmojiInput = currentValue.substring(0, currentValue.length - previousValue.length);
}
......
......@@ -228,7 +228,7 @@ export class TypeOperations {
let goodIndent = this._goodIndentForLine(config, model, selection.startLineNumber);
goodIndent = goodIndent || '\t';
let possibleTypeText = config.normalizeIndentation(goodIndent);
if (!strings.startsWith(lineText, possibleTypeText)) {
if (!lineText.startsWith(possibleTypeText)) {
commands[i] = new ReplaceCommand(new Range(selection.startLineNumber, 1, selection.startLineNumber, lineText.length + 1), possibleTypeText, true);
continue;
}
......
......@@ -363,7 +363,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
}
if (e.searchString || e.matchesCount || e.matchesPosition) {
let showRedOutline = (this._state.searchString.length > 0 && this._state.matchesCount === 0);
dom.toggleClass(this._domNode, 'no-results', showRedOutline);
this._domNode.classList.toggle('no-results', showRedOutline);
this._updateMatchesCount();
this._updateButtons();
......@@ -477,7 +477,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
this._replaceBtn.setEnabled(this._isVisible && this._isReplaceVisible && findInputIsNonEmpty);
this._replaceAllBtn.setEnabled(this._isVisible && this._isReplaceVisible && findInputIsNonEmpty);
dom.toggleClass(this._domNode, 'replaceToggled', this._isReplaceVisible);
this._domNode.classList.toggle('replaceToggled', this._isReplaceVisible);
this._toggleReplaceBtn.setExpanded(this._isReplaceVisible);
let canReplace = !this._codeEditor.getOption(EditorOption.readOnly);
......@@ -510,7 +510,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
this._updateButtons();
setTimeout(() => {
dom.addClass(this._domNode, 'visible');
this._domNode.classList.add('visible');
this._domNode.setAttribute('aria-hidden', 'false');
}, 0);
......@@ -557,7 +557,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
this._updateButtons();
dom.removeClass(this._domNode, 'visible');
this._domNode.classList.remove('visible');
this._domNode.setAttribute('aria-hidden', 'true');
this._findInput.clearMessage();
if (focusTheEditor) {
......@@ -695,10 +695,10 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
if (editorContentWidth <= 0) {
// for example, diff view original editor
dom.addClass(this._domNode, 'hiddenEditor');
this._domNode.classList.add('hiddenEditor');
return;
} else if (dom.hasClass(this._domNode, 'hiddenEditor')) {
dom.removeClass(this._domNode, 'hiddenEditor');
} else if (this._domNode.classList.contains('hiddenEditor')) {
this._domNode.classList.remove('hiddenEditor');
}
const editorWidth = layoutInfo.width;
......@@ -727,9 +727,9 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
if (FIND_WIDGET_INITIAL_WIDTH + 28 + minimapWidth - MAX_MATCHES_COUNT_WIDTH >= editorWidth + 50) {
collapsedFindWidget = true;
}
dom.toggleClass(this._domNode, 'collapsed-find-widget', collapsedFindWidget);
dom.toggleClass(this._domNode, 'narrow-find-widget', narrowFindWidget);
dom.toggleClass(this._domNode, 'reduced-find-widget', reducedFindWidget);
this._domNode.classList.toggle('collapsed-find-widget', collapsedFindWidget);
this._domNode.classList.toggle('narrow-find-widget', narrowFindWidget);
this._domNode.classList.toggle('reduced-find-widget', reducedFindWidget);
if (!narrowFindWidget && !collapsedFindWidget) {
// the minimal left offset of findwidget is 15px.
......@@ -1306,7 +1306,7 @@ export class SimpleButton extends Widget {
}
public setEnabled(enabled: boolean): void {
dom.toggleClass(this._domNode, 'disabled', !enabled);
this._domNode.classList.toggle('disabled', !enabled);
this._domNode.setAttribute('aria-disabled', String(!enabled));
this._domNode.tabIndex = enabled ? 0 : -1;
}
......
......@@ -3,7 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as dom from 'vs/base/browser/dom';
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { Widget } from 'vs/base/browser/ui/widget';
import { KeyCode } from 'vs/base/common/keyCodes';
......@@ -35,7 +34,7 @@ export class ContentHoverWidget extends Widget implements IContentWidget {
protected set isVisible(value: boolean) {
this._isVisible = value;
dom.toggleClass(this._hover.containerDomNode, 'hidden', !this._isVisible);
this._hover.containerDomNode.classList.toggle('hidden', !this._isVisible);
}
constructor(
......@@ -203,7 +202,7 @@ export class GlyphHoverWidget extends Widget implements IOverlayWidget {
protected set isVisible(value: boolean) {
this._isVisible = value;
dom.toggleClass(this._domNode, 'hidden', !this._isVisible);
this._domNode.classList.toggle('hidden', !this._isVisible);
}
public getId(): string {
......
......@@ -28,7 +28,6 @@ import { EditorOption } from 'vs/editor/common/config/editorOptions';
import { URI } from 'vs/base/common/uri';
import { Schemas } from 'vs/base/common/network';
import * as resources from 'vs/base/common/resources';
import * as strings from 'vs/base/common/strings';
function getHoverMessage(link: Link, useMetaKey: boolean): MarkdownString {
const executeCmd = link.url && /^command:/i.test(link.url.toString());
......@@ -299,15 +298,15 @@ export class LinkDetector implements IEditorContribution {
// Support for relative file URIs of the shape file://./relativeFile.txt or file:///./relativeFile.txt
if (typeof uri === 'string' && this.editor.hasModel()) {
const modelUri = this.editor.getModel().uri;
if (modelUri.scheme === Schemas.file && strings.startsWith(uri, 'file:')) {
if (modelUri.scheme === Schemas.file && uri.startsWith('file:')) {
const parsedUri = URI.parse(uri);
if (parsedUri.scheme === Schemas.file) {
const fsPath = resources.originalFSPath(parsedUri);
let relativePath: string | null = null;
if (strings.startsWith(fsPath, '/./')) {
if (fsPath.startsWith('/./')) {
relativePath = `.${fsPath.substr(1)}`;
} else if (strings.startsWith(fsPath, '//./')) {
} else if (fsPath.startsWith('//./')) {
relativePath = `.${fsPath.substr(2)}`;
}
......
......@@ -451,7 +451,7 @@ export abstract class ZoneWidget implements IHorizontalSashLayoutProvider {
this.container.classList.remove(classToReplace);
}
dom.addClass(this.container, className);
this.container.classList.add(className);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册