var VNode = require('./vnode'); var is = require('./is'); function addNS(data, children) { data.ns = 'http://www.w3.org/2000/svg'; if (children !== undefined) { for (var i = 0; i < children.length; ++i) { addNS(children[i].data, children[i].children); } } } 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]); } } if (sel[0] === 's' && sel[1] === 'v' && sel[2] === 'g') { addNS(data, children); } return VNode(sel, data, children, text, undefined); };