clearMountPoint method

void clearMountPoint(
  1. HTMLElement mountPoint
)

Implementation

void clearMountPoint(HTMLElement mountPoint) {
  final List<Node> children = <Node>[];
  final NodeList nodeList = mountPoint.childNodes;

  // Creamos una copia de los nodos porque vamos a modificarlos
  for (int i = 0; i < nodeList.length; i++) {
    final Node? child = nodeList.item(i);
    if (child != null) {
      children.add(child);
    }
  }

  // Eliminamos cada hijo referenciando al padre
  for (final Node child in children) {
    mountPoint.removeChild(child);
  }
}