function h(tagName, text, attributes, children) { /* allow for not adding text */ if (children === undefined && typeof(text) === 'object') { children = attributes; attributes = text; text = null; } /* allow for not adding attributes */ if (children === undefined && Array.isArray(attributes)) { children = attributes; attributes = {}; } /* allow for not adding children */ if (children === undefined) { children = []; } const element = document.createElement(tagName); if (text) element.appendChild(document.createTextNode(text)); for (let key in attributes) { const value = attributes[key]; element.setAttribute(key, value); } for (let child of children) element.appendChild(child); return element; } export default h;