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
28 lines (24 loc) • 669 B
JavaScript
export function h(name, attributes) {
var rest = []
var children = []
var length = arguments.length
while (length-- > 2) rest.push(arguments[length])
while (rest.length) {
var node = rest.pop()
if (node && node.pop) {
for (length = node.length; length--; ) {
rest.push(node[length])
}
} else if (node != null && node !== true && node !== false) {
children.push(node)
}
}
return typeof name === "function"
? name(attributes || {}, children) // h(Component)
: {
nodeName: name,
attributes: attributes || {},
children: children,
key: attributes && attributes.key
}
}