code: private static void replaceOrAppend(Element oldElement, Element newElement) {
      assert oldElement != null && newElement != null;
  
      if (matchesTags(oldElement, appendingTags)) {
        GQuery.$(oldElement).html("").append(newElement);
      } else {
        GQuery.$(oldElement).replaceWith(newElement);
  
        // copy class
        String c = oldElement.getClassName();
        if (!c.isEmpty()) {
          newElement.addClassName(c);
        }
        // copy id
        newElement.setId(oldElement.getId());
        // ensure no duplicate id
        oldElement.setId("");
      }
    }
docs: If the <code>oldElement</code> is a td, th, li tags, the new element will replaced its content.
  In other cases, the <code>oldElement</code> will be replaced by the <code>newElement</code>
  and the old element classes will be copied to the new element.