mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-10 17:53:55 +01:00
27 lines
681 B
TypeScript
27 lines
681 B
TypeScript
/**
|
|
* For a given element, this function removes it AND its children
|
|
* @param elem The element to remove.
|
|
*/
|
|
export function removeElement(elem: Element | null): void {
|
|
if (elem === null) {
|
|
// tslint:disable-next-line:no-console
|
|
console.debug("The element passed into 'removeElement' was null.");
|
|
|
|
return;
|
|
}
|
|
if (!(elem instanceof Element)) {
|
|
// tslint:disable-next-line:no-console
|
|
console.debug("The element passed into 'removeElement' was not an instance of an Element.");
|
|
|
|
return;
|
|
}
|
|
|
|
while (elem.firstChild !== null) {
|
|
elem.removeChild(elem.firstChild);
|
|
}
|
|
|
|
if (elem.parentNode !== null) {
|
|
elem.parentNode.removeChild(elem);
|
|
}
|
|
}
|