diff --git a/src/vs/base/browser/dom.ts b/src/vs/base/browser/dom.ts index 24ac47e58e4..bbb81a0b407 100644 --- a/src/vs/base/browser/dom.ts +++ b/src/vs/base/browser/dom.ts @@ -24,6 +24,9 @@ export function clearNode(node: HTMLElement): void { } } +/** + * @deprecated Use node.isConnected directly + */ export function isInDOM(node: Node | null): boolean { return node?.isConnected ?? false; } @@ -998,9 +1001,13 @@ export function after(sibling: HTMLElement, child: T): T { return child; } -export function append(parent: HTMLElement, ...children: T[]): T { +export function append(parent: HTMLElement, child: T): T; +export function append(parent: HTMLElement, ...children: (T | string)[]): void; +export function append(parent: HTMLElement, ...children: (T | string)[]): T | void { parent.append(...children); - return children[children.length - 1]; + if (children.length === 1 && typeof children[0] !== 'string') { + return children[0]; + } } export function prepend(parent: HTMLElement, child: T): T { @@ -1008,20 +1015,12 @@ export function prepend(parent: HTMLElement, child: T): T { return child; } - /** * Removes all children from `parent` and appends `children` */ export function reset(parent: HTMLElement, ...children: Array): void { parent.innerText = ''; - appendChildren(parent, ...children); -} - -/** - * Appends `children` to `parent` - */ -export function appendChildren(parent: HTMLElement, ...children: Array): void { - parent.append(...children); + append(parent, ...children); } const SELECTOR_REGEX = /([\w\-]+)?(#([\w\-]+))?((\.([\w\-]+))*)/; diff --git a/src/vs/workbench/browser/parts/statusbar/statusbarPart.ts b/src/vs/workbench/browser/parts/statusbar/statusbarPart.ts index 2e77f75e627..10ac9fa8ece 100644 --- a/src/vs/workbench/browser/parts/statusbar/statusbarPart.ts +++ b/src/vs/workbench/browser/parts/statusbar/statusbarPart.ts @@ -21,7 +21,7 @@ import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/ import { contrastBorder, activeContrastBorder } from 'vs/platform/theme/common/colorRegistry'; import { isThemeColor } from 'vs/editor/common/editorCommon'; import { Color } from 'vs/base/common/color'; -import { EventHelper, createStyleSheet, addDisposableListener, EventType, hide, show, isAncestor, appendChildren } from 'vs/base/browser/dom'; +import { EventHelper, createStyleSheet, addDisposableListener, EventType, hide, show, isAncestor, append } from 'vs/base/browser/dom'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { IStorageService, StorageScope, IStorageValueChangeEvent, StorageTarget } from 'vs/platform/storage/common/storage'; import { Parts, IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; @@ -750,7 +750,7 @@ class StatusBarCodiconLabel extends SimpleIconLabel { } // Append new elements - appendChildren(this.container, ...renderLabelWithIcons(textContent)); + append(this.container, ...renderLabelWithIcons(textContent)); } // No Progress: no special handling