tsx:support array in children

This commit is contained in:
pengfei.zhou
2021-09-02 14:31:24 +08:00
committed by osborn
parent 03633a7bea
commit 266d20782a
8 changed files with 100 additions and 39 deletions

View File

@@ -3640,6 +3640,20 @@ exports.Display = void 0;
exports.jsx = void 0;
(function (jsx) {
function addElement(group, v) {
if (v instanceof Array) {
v.forEach(e => addElement(group, e));
}
else if (v instanceof Fragment) {
v.children.forEach(e => addElement(group, e));
}
else if (v instanceof View) {
group.addChild(v);
}
else {
throw new Error(`Can only use view as child`);
}
}
function createElement(constructor, config, ...children) {
const e = new constructor();
e.layoutConfig = layoutConfig().fit();
@@ -3649,12 +3663,7 @@ exports.jsx = void 0;
if (children && children.length > 0) {
if (e instanceof Group) {
children.forEach((child) => {
if (child instanceof Fragment) {
child.children.forEach(c => e.addChild(c));
}
else {
e.addChild(child);
}
addElement(e, child);
});
}
else {

File diff suppressed because one or more lines are too long