##// END OF EJS Templates
fixed isNode, isWidget, isRendition type predicated, fixed handling primitive values
cin -
r127:8095aad89415 v1.7.1 default
parent child
Show More
@@ -27,7 +27,7 export interface IRecursivelyDestroyable
27 destroyRecursive(): void;
27 destroyRecursive(): void;
28 }
28 }
29
29
30 export const isNode = (el: unknown): el is Node => !!(el && (el as Node).nodeName && (el as Node).nodeType);
30 export const isNode = (el: unknown): el is Node => !!(el !== null && typeof el === "object" && (el as Node).nodeName && (el as Node).nodeType);
31
31
32 export const isElementNode = (el: unknown): el is Element => isNode(el) && el.nodeType === 1;
32 export const isElementNode = (el: unknown): el is Element => isNode(el) && el.nodeType === 1;
33
33
@@ -43,9 +43,9 export const isDocumentTypeNode = (el: u
43
43
44 export const isDocumentFragmentNode = (el: unknown): el is DocumentFragment => isNode(el) && el.nodeType === 11;
44 export const isDocumentFragmentNode = (el: unknown): el is DocumentFragment => isNode(el) && el.nodeType === 11;
45
45
46 export const isWidget = (v: unknown): v is _WidgetBase => !!(v && "domNode" in (v as _WidgetBase));
46 export const isWidget = (v: unknown): v is _WidgetBase => !!(v !== null && typeof v === "object" && "domNode" in (v as _WidgetBase));
47
47
48 export const isRendition = (v: unknown): v is Rendition => !!(v && typeof (v as Rendition).getDomNode === "function");
48 export const isRendition = (v: unknown): v is Rendition => !!(v !== null && typeof v === "object" && typeof (v as Rendition).getDomNode === "function");
49
49
50 /**
50 /**
51 * @deprecated use isRendition
51 * @deprecated use isRendition
General Comments 0
You need to be logged in to leave comments. Login now