src/ui/components/component.js
function destroy() {
    if (this.properties._internalState.onDestroyCalled) return;
    if (this.parentNode) {
      this.parentNode.removeChild(this);
    }
    Object.keys(this.nodes || {}).forEach((name) => {
      if (this.nodes[name] && this.nodes[name].destroy) this.nodes[name].destroy();
    });
    this.onDestroy();
  }
function destroy() {
    if (this.properties._internalState.onDestroyCalled) return;
    if (this.parentNode) {
      this.parentNode.removeChild(this);
    }
    Object.keys(this.nodes || {}).forEach((name) => {
      if (this.nodes[name] && this.nodes[name].destroy) this.nodes[name].destroy();
    });
    this.onDestroy();
  }
function destroy ( ) { if ( this . properties . _internalState . onDestroyCalled ) return ; if ( this . parentNode ) { this . parentNode . removeChild ( this ) ; } Object . keys ( this . nodes || { } ) . forEach ( ( name ) => { if ( this . nodes [ name ] && this . nodes [ name ] . destroy ) this . nodes [ name ] . destroy ( ) ; } ) ; this . onDestroy ( ) ; }
Call this to destroy the UI Component.

Destroying will cause it to be removed from its parent node, it will call destroy on all child nodes,
and then call the {@link #onDestroy} method.

> *Note*
>
> destroy is called to remove a component, but it is not a lifecycle method; a component that has been removed
> from the DOM some otherway will cause {@link #onDestroy} to be called but `destroy()` will _not_ be called.

@method destroy
Call this to destroy the UI Component .