Skip to content

Commit 8db4848

Browse files
committed
Handle null and undefined
1 parent bec3edf commit 8db4848

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "simple-tsx",
3-
"version": "1.0.2",
3+
"version": "1.1.0",
44
"description": "A simple way to write tsx files. No babel required!",
55
"main": "dist/index.js",
66
"type": "commonjs",

src/element.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default class Element {
66
constructor(
77
tagName: string,
88
attributes: AttributesType | null,
9-
...children: (Element | string | number)[]
9+
...children: (Element | string | number | null | undefined)[]
1010
) {
1111
this.element = document.createElement(tagName);
1212
const trueAttributes = attributes || {};
@@ -26,6 +26,8 @@ export default class Element {
2626
node = document.createTextNode(child);
2727
} else if (typeof child === "number") {
2828
node = document.createTextNode(child.toString());
29+
} else if (child === null || child === undefined) {
30+
return;
2931
} else {
3032
node = child.element;
3133
}

0 commit comments

Comments
 (0)