Do you think this could be cleaner if we used apis like `document.createElement` and `Node.appendChild`?