You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
snabbdom/h.js

22 lines
657 B
JavaScript

var VNode = require('./vnode');
var is = require('./is');
module.exports = function h(sel, b, c) {
var data = {}, children, text, i;
if (arguments.length === 3) {
data = b;
if (is.array(c)) { children = c; }
else if (is.primitive(c)) { text = c; }
} else if (arguments.length === 2) {
if (is.array(b)) { children = b; }
else if (is.primitive(b)) { text = b; }
else { data = b; }
}
if (is.array(children)) {
for (i = 0; i < children.length; ++i) {
if (is.primitive(children[i])) children[i] = VNode(undefined, undefined, undefined, children[i]);
}
}
return VNode(sel, data, children, text, undefined);
};