# HG changeset patch # User cin # Date 2023-01-25 11:04:41 # Node ID 8095aad89415099d8e1942a8e67050c22e111d8b # Parent 57b65a506e4f583c6bd8bfc5b6bf288e4467172f fixed isNode, isWidget, isRendition type predicated, fixed handling primitive values diff --git a/djx/src/main/ts/tsx/traits.ts b/djx/src/main/ts/tsx/traits.ts --- a/djx/src/main/ts/tsx/traits.ts +++ b/djx/src/main/ts/tsx/traits.ts @@ -27,7 +27,7 @@ export interface IRecursivelyDestroyable destroyRecursive(): void; } -export const isNode = (el: unknown): el is Node => !!(el && (el as Node).nodeName && (el as Node).nodeType); +export const isNode = (el: unknown): el is Node => !!(el !== null && typeof el === "object" && (el as Node).nodeName && (el as Node).nodeType); export const isElementNode = (el: unknown): el is Element => isNode(el) && el.nodeType === 1; @@ -43,9 +43,9 @@ export const isDocumentTypeNode = (el: u export const isDocumentFragmentNode = (el: unknown): el is DocumentFragment => isNode(el) && el.nodeType === 11; -export const isWidget = (v: unknown): v is _WidgetBase => !!(v && "domNode" in (v as _WidgetBase)); +export const isWidget = (v: unknown): v is _WidgetBase => !!(v !== null && typeof v === "object" && "domNode" in (v as _WidgetBase)); -export const isRendition = (v: unknown): v is Rendition => !!(v && typeof (v as Rendition).getDomNode === "function"); +export const isRendition = (v: unknown): v is Rendition => !!(v !== null && typeof v === "object" && typeof (v as Rendition).getDomNode === "function"); /** * @deprecated use isRendition