mini-jsx-test-pb 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -38,6 +38,10 @@ function mountChild(parent, child) {
|
|
|
38
38
|
for (const c of child) mountChild(parent, c);
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
|
+
if (child instanceof Node) {
|
|
42
|
+
parent.appendChild(child);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
41
45
|
if (typeof child === "function") {
|
|
42
46
|
const text = document.createTextNode("");
|
|
43
47
|
parent.appendChild(text);
|
|
@@ -51,17 +55,13 @@ function mountChild(parent, child) {
|
|
|
51
55
|
mountChild(parent, () => child.val);
|
|
52
56
|
return;
|
|
53
57
|
}
|
|
54
|
-
if (child instanceof Node) {
|
|
55
|
-
parent.appendChild(child);
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
58
|
parent.appendChild(document.createTextNode(String(child)));
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
// src/jsx.ts
|
|
62
|
-
function h(type, props, ...
|
|
62
|
+
function h(type, props, ...rest) {
|
|
63
63
|
if (typeof type === "function") {
|
|
64
|
-
return type(
|
|
64
|
+
return type(props ?? {});
|
|
65
65
|
}
|
|
66
66
|
const el = document.createElement(type);
|
|
67
67
|
if (props) {
|
|
@@ -75,8 +75,8 @@ function h(type, props, ...restChildren) {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
const children =
|
|
79
|
-
for (const child of children
|
|
78
|
+
const children = rest.length > 0 ? rest : props?.children != null ? Array.isArray(props.children) ? props.children : [props.children] : [];
|
|
79
|
+
for (const child of children) {
|
|
80
80
|
mountChild(el, child);
|
|
81
81
|
}
|
|
82
82
|
return el;
|
package/dist/index.js
CHANGED
package/dist/jsx-dev-runtime.js
CHANGED
package/dist/jsx-runtime.js
CHANGED