aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoris2025-04-08 09:17:33 +0200
committerJoris2025-04-08 09:17:33 +0200
commit8764c628d32e3e0bcb9f819d384df4761dbc060a (patch)
tree3070478d5e44eaf336ea5214c8fe36315658d2c1 /src
parentcaab0dbe773a1855238c5d1d1b7d70f578fb3f51 (diff)
Allow using null
Diffstat (limited to 'src')
-rw-r--r--src/rx.ts22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/rx.ts b/src/rx.ts
index 48db4fd..9884de8 100644
--- a/src/rx.ts
+++ b/src/rx.ts
@@ -5,6 +5,7 @@
export type Html
= false
| undefined
+ | null
| string
| number
| Tag
@@ -68,6 +69,7 @@ interface Attributes {
type AttributeValue
= undefined
+ | null
| string
| number
| boolean
@@ -93,7 +95,7 @@ export function h(
x?: Attributes | Html,
...children: Array<Html>
): Tag {
- if (x === undefined || x === false) {
+ if (x === undefined || x == null || x === false) {
return {
type: 'Tag',
tagName,
@@ -411,7 +413,7 @@ function rxRun<A>(
}
function isRx<A>(x: any): x is Rx<A> {
- return x !== undefined && x.type !== undefined && (x.type === "Var" || x.type === "Map" || x.type === "FlatMap" || x.type === 'Sequence' || x.type === 'Pure')
+ return x != null && x.type !== undefined && (x.type === "Var" || x.type === "Map" || x.type === "FlatMap" || x.type === 'Sequence' || x.type === 'Pure')
}
function isPure<A>(x: any): x is Pure<A> {
@@ -646,7 +648,7 @@ function appendChild(state: State, element: Element, child: Html, lastAdded?: No
},
lastAdded: appendRes.lastAdded,
}
- } else if (child === undefined || child === false) {
+ } else if (!child) {
return {
cancel: voidCancel,
remove: voidRemove,
@@ -663,31 +665,31 @@ function isSvg(tagName: string): boolean {
}
function isTag<A>(x: any): x is Tag {
- return x !== undefined && x.type === "Tag"
+ return x != null && x.type === "Tag"
}
function isWithState<A>(x: any): x is WithState<A> {
- return x !== undefined && x.type === "WithState"
+ return x != null && x.type === "WithState"
}
function isWithState2<A, B>(x: any): x is WithState2<A, B> {
- return x !== undefined && x.type === "WithState2"
+ return x != null && x.type === "WithState2"
}
function isWithState3<A, B, C>(x: any): x is WithState3<A, B, C> {
- return x !== undefined && x.type === "WithState3"
+ return x != null && x.type === "WithState3"
}
function isWithState4<A, B, C, D>(x: any): x is WithState4<A, B, C, D> {
- return x !== undefined && x.type === "WithState4"
+ return x != null && x.type === "WithState4"
}
function isWithState5<A, B, C, D, E>(x: any): x is WithState5<A, B, C, D, E> {
- return x !== undefined && x.type === "WithState5"
+ return x != null && x.type === "WithState5"
}
function isWithState6<A, B, C, D, E, F>(x: any): x is WithState6<A, B, C, D, E, F> {
- return x !== undefined && x.type === "WithState6"
+ return x != null && x.type === "WithState6"
}
function appendNode(base: Element, node: Node, lastAdded?: Node) {