diff --git a/src/core/h.js b/src/core/h.js new file mode 100644 index 000000000..d853c1e7b --- /dev/null +++ b/src/core/h.js @@ -0,0 +1,35 @@ +BI.Fragment = function () { +}; + +BI.h = function (type, props, children) { + if (children != null) { + if (!BI.isArray(children)) { + children = [children]; + } + } else { + children = []; + } + if (arguments.length > 3) { + for (var i = 3; i < arguments.length; i++) { + if (BI.isArray(arguments[i])) { + children = children.concat(arguments[i]); + } else { + children.push(arguments[i]); + } + } + } + if (type === BI.Fragment) { + return children; + } + if (BI.isFunction(type)) { + type = type.xtype; + } + if (type === "el") { + return BI.extend({ + el: children[0] + }, props); + } + return BI.extend({ + type: type, + }, children.length > 0 ? {items: children} : {}, props); +}; \ No newline at end of file