diff --git a/libraries/stdlib/src/kotlin/dom/Dom.kt b/libraries/stdlib/src/kotlin/dom/Dom.kt index 226bf17a042..2d2d11fb025 100644 --- a/libraries/stdlib/src/kotlin/dom/Dom.kt +++ b/libraries/stdlib/src/kotlin/dom/Dom.kt @@ -246,7 +246,17 @@ class ElementListAsList(val nodeList: NodeList): AbstractList() { } - +/** Removes all the children from this node */ +fun Node.clear(): Unit { + while (true) { + val child = firstChild + if (child == null) { + return + } else { + removeChild(child) + } + } +} /** Returns an [[Iterator]] over the next siblings of this node */ fun Node.nextSiblings() : Iterator = NextSiblingIterator(this)