[chore] TSLint cleanup

This commit is contained in:
Steven Evans
2018-07-08 01:11:34 -04:00
parent 28bebeb144
commit 41fbf63f0d
7 changed files with 94 additions and 43 deletions
+6 -1
View File
@@ -1,6 +1,11 @@
import { isString } from "../helpers/isString";
import { getElementById } from "./getElementById";
/**
* Clears out all children from the provided element.
* If a string is passed in, it will treat it as an ID and search for the element to delete all children from.
* @param el The element or ID of an element to remove all children from.
*/
export function removeChildrenFromElement(el: string | null | Element) {
if (el === null) {
return;
@@ -10,7 +15,7 @@ export function removeChildrenFromElement(el: string | null | Element) {
const elem: HTMLElement | Element = (isString(el) ? getElementById(el as string) : el as Element);
if (elem instanceof Element) {
while (elem.firstChild) {
while (elem.firstChild !== null) {
elem.removeChild(elem.firstChild);
}
}