const renderElement = ({tagName, attrs, children}) => { const element = document.createElement(tagName); // set attributes for (const [k, v] of Object.entries(attrs)) { element.setAttribute(k, v); } // set children for (const child of children) { const $child = render(child); element.appendChild($child); } return element; }; const render = (vNode) => { if (typeof vNode === 'string') { return document.createTextNode(vNode); } return renderElement(vNode); } export default render;