UNPKG

pop

Version:

Pop is a [Hyperapp](https://github.com/hyperapp/hyperapp) / [Ultradom](https://github.com/ultradom/ultradom) spin-off project — yet another micro-framework for creating graphical user interfaces. This is not the final title, but let's go with that for now

30 lines (24 loc) 843 B
import { updateAttribute } from "./updateAttribute" export function createElement(node, lifecycle, isSVG) { var element = typeof node === "string" || typeof node === "number" ? document.createTextNode(node) : (isSVG = isSVG || node.nodeName === "svg") ? document.createElementNS("http://www.w3.org/2000/svg", node.nodeName) : document.createElement(node.nodeName) var attributes = node.attributes if (attributes) { if (attributes.oncreate) { lifecycle.push(function() { attributes.oncreate(element) }) } for (var i = 0; i < node.children.length; i++) { element.appendChild(createElement(node.children[i], lifecycle, isSVG)) } for (var name in attributes) { updateAttribute(element, name, attributes[name], null, isSVG) } } return element }