Skip to content

Instantly share code, notes, and snippets.

@pomber
Last active April 25, 2017 19:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pomber/99930ade6f4d1b90f1e545013776d149 to your computer and use it in GitHub Desktop.
Save pomber/99930ade6f4d1b90f1e545013776d149 to your computer and use it in GitHub Desktop.
function render(rootDom, element) {
const { type, props } = element;
const dom = document.createElement(type);
Object.keys(props).filter(isAttribute).forEach(name => {
dom[name] = props[name];
});
const children = props.children || [];
children.forEach(childElement => render(dom, childElement));
rootDom.appendChild(dom);
}
const isAttribute = name => name != "children";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment