remove()

in JSDOMParser.js [372:410]


    remove() {
      let parent = this.parentNode;
      if (!parent) {
        // We were already detached so there's nothing to do.
        return this;
      }
      var childNodes = parent.childNodes;
      var childIndex = childNodes.indexOf(this);
      if (childIndex === -1) {
        throw new Error("removeChild: node not found");
      }
      this.parentNode = null;
      var prev = this.previousSibling;
      var next = this.nextSibling;
      if (prev) {
        prev.nextSibling = next;
      }
      if (next) {
        next.previousSibling = prev;
      }
      childNodes.splice(childIndex, 1);

      if (this.nodeType === Node.ELEMENT_NODE) {
        prev = this.previousElementSibling;
        next = this.nextElementSibling;
        if (prev) {
          prev.nextElementSibling = next;
        }
        if (next) {
          next.previousElementSibling = prev;
        }
        parent.children.splice(parent.children.indexOf(this), 1);
      }

      this.previousSibling = this.nextSibling = null;
      this.previousElementSibling = this.nextElementSibling = null;

      return this;
    },