Add dom.toggleVisibility helper (#175960)

Adds a helper function for toggling if a set of elements are visible or hidden
This commit is contained in:
Matt Bierner
2023-03-06 11:31:26 -08:00
committed by GitHub
parent 4c60cc59ef
commit 43b6e7785d
3 changed files with 12 additions and 16 deletions

View File

@@ -1040,6 +1040,14 @@ export function join(nodes: Node[], separator: Node | string): Node[] {
return result;
}
export function setVisibility(visible: boolean, ...elements: HTMLElement[]): void {
if (visible) {
show(...elements);
} else {
hide(...elements);
}
}
export function show(...elements: HTMLElement[]): void {
for (const element of elements) {
element.style.display = '';