##// END OF EJS Templates
* tsx/{Xxx}Context renamed to tsx/{Xxx}Rendition, for old types made...
* tsx/{Xxx}Context renamed to tsx/{Xxx}Rendition, for old types made compatibility stubs with @deprected comments * Improved handling of functional component output, added support for boolean, null, undefined and widgets. * RenditionBase: fixed startup for the DocumentFragment nodes * startupWidgets: fixed startup of the widget when passed domNode of the widget. * DjxFragment converted to the functional component

File last commit:

r63:1a0018655d1c v1.1.0 default
r63:1a0018655d1c v1.1.0 default
Show More
tsx.ts
40 lines | 1.3 KiB | video/mp2t | TypeScriptLexer
import { Constructor } from "@implab/core-amd/interfaces";
import { HtmlRendition } from "./tsx/HtmlRendition";
import { WidgetRendition } from "./tsx/WidgetRendition";
import { isWidgetConstructor, Rendition } from "./tsx/traits";
import { FunctionRendition } from "./tsx/FunctionRendition";
export function createElement<T extends Constructor | string | ((props: any) => Element)>(elementType: T, ...args: any[]): Rendition {
if (typeof elementType === "string") {
const ctx = new HtmlRendition(elementType);
if (args)
args.forEach(x => ctx.visitNext(x));
return ctx;
} else if (isWidgetConstructor(elementType)) {
const ctx = new WidgetRendition(elementType);
if (args)
args.forEach(x => ctx.visitNext(x));
return ctx;
} else if (typeof elementType === "function") {
const ctx = new FunctionRendition(elementType as (props: any) => Element);
if (args)
args.forEach(x => ctx.visitNext(x));
return ctx;
} else {
throw new Error(`The element type '${elementType}' is unsupported`);
}
}
export interface EventDetails<T = any> {
detail: T;
}
export interface EventSelector {
selectorTarget: HTMLElement;
target: HTMLElement;
}
export type DojoMouseEvent<T = any> = MouseEvent & EventSelector & EventDetails<T>;