From fcb76d33b40f1dfc13ac91d8ed65236051fa204b Mon Sep 17 00:00:00 2001 From: guy Date: Sat, 8 May 2021 22:04:10 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=96=B0=E5=A2=9Eh=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/h.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/core/h.js diff --git a/src/core/h.js b/src/core/h.js new file mode 100644 index 000000000..a8bf3e29d --- /dev/null +++ b/src/core/h.js @@ -0,0 +1,19 @@ +BI.Fragment = function () { +}; + +BI.h = function (type, props, children) { + 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({ + items: children + }, props); +}; \ No newline at end of file From a4c4a2edbc382479cb59e5c4aeb20594a7026ba7 Mon Sep 17 00:00:00 2001 From: guy Date: Sat, 8 May 2021 22:16:06 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=96=B0=E5=A2=9Eh=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/h.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/h.js b/src/core/h.js index a8bf3e29d..fa90dfa6d 100644 --- a/src/core/h.js +++ b/src/core/h.js @@ -14,6 +14,7 @@ BI.h = function (type, props, children) { }, props); } return BI.extend({ + type: type, items: children }, props); }; \ No newline at end of file From 402acaa13531826a1047e76c1a49f06b59963b32 Mon Sep 17 00:00:00 2001 From: guy Date: Sat, 8 May 2021 22:20:07 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=96=B0=E5=A2=9Eh=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/h.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/h.js b/src/core/h.js index fa90dfa6d..04bb4ed42 100644 --- a/src/core/h.js +++ b/src/core/h.js @@ -10,11 +10,11 @@ BI.h = function (type, props, children) { } if (type === "el") { return BI.extend({ - el: children[0] + el: BI.isArray(children) ? children[0] : children }, props); } return BI.extend({ type: type, - items: children + items: BI.isArray(children) ? children : [children] }, props); }; \ No newline at end of file From e691b578d91d402e21019d267b16223cc00df08d Mon Sep 17 00:00:00 2001 From: guy Date: Sat, 8 May 2021 22:38:42 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=96=B0=E5=A2=9Eh=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/h.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/core/h.js b/src/core/h.js index 04bb4ed42..d853c1e7b 100644 --- a/src/core/h.js +++ b/src/core/h.js @@ -2,6 +2,22 @@ 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; } @@ -10,11 +26,10 @@ BI.h = function (type, props, children) { } if (type === "el") { return BI.extend({ - el: BI.isArray(children) ? children[0] : children + el: children[0] }, props); } return BI.extend({ type: type, - items: BI.isArray(children) ? children : [children] - }, props); + }, children.length > 0 ? {items: children} : {}, props); }; \ No newline at end of file