diff options
Diffstat (limited to 'src/rx.ts')
-rw-r--r-- | src/rx.ts | 22 |
1 files changed, 12 insertions, 10 deletions
@@ -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) { |