##// END OF EJS Templates
Added tag v1.0.0-rc2 for changeset fc9f82c082ef
Added tag v1.0.0-rc2 for changeset fc9f82c082ef

File last commit:

r4:fc9f82c082ef v1.0.0-rc2 default
r5:e5727b40aba0 default
Show More
djx.ts
33 lines | 1.0 KiB | video/mp2t | TypeScriptLexer
cin
switched back to dojo-typings module...
r4 import { Constructor } from "@implab/core-amd/interfaces";
import { HtmlElementContext } from "./djx/HtmlElementContext";
import { WidgetContext } from "./djx/WidgetContext";
import { isWidgetConstructor, BuildContext } from "./djx/traits";
export function createElement<T extends Constructor>(elementType: string | T, ...args: any[]): BuildContext {
if (typeof elementType === "string") {
const ctx = new HtmlElementContext(elementType);
if (args)
args.forEach(x => ctx.visitNext(x));
return ctx;
} else if (isWidgetConstructor(elementType)) {
const ctx = new WidgetContext(elementType);
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>;