##// END OF EJS Templates
Support for Function Components...
Support for Function Components Added JSX.IntrinsicElements

File last commit:

r34:e8012fdf09ae 1.0.0-rc16 default
r34:e8012fdf09ae 1.0.0-rc16 default
Show More
WidgetContext.ts
51 lines | 1.4 KiB | video/mp2t | TypeScriptLexer
/ src / main / ts / tsx / WidgetContext.ts
cin
sync
r7 import dom = require("dojo/dom-construct");
import { argumentNotNull } from "@implab/core-amd/safe";
import { BuildContextBase } from "./BuildContextBase";
cin
Added DjxFragment...
r19 import { MapOf } from "@implab/core-amd/interfaces";
cin
sync
r7
cin
Added DjxFragment...
r19 // tslint:disable-next-line: class-name
export interface _Widget {
domNode: Node;
get(attr: string): any;
set(attr: string, value: any): void;
set(attrs: MapOf<any>): void;
containerNode?: Node
}
export type _WidgetCtor = new (attrs: any, srcNode?: string | Node) => _Widget;
cin
sync
r7
cin
Switched to dojo-typings...
r22 export class WidgetContext extends BuildContextBase<Node> {
cin
Added DjxFragment...
r19 widgetClass: _WidgetCtor;
cin
sync
r7
cin
Added DjxFragment...
r19 _instance: _Widget | undefined;
cin
sync
r7
cin
Added DjxFragment...
r19 constructor(widgetClass: _WidgetCtor) {
cin
sync
r7 super();
argumentNotNull(widgetClass, "widgetClass");
this.widgetClass = widgetClass;
}
_addChild(child: any): void {
if (!this._instance || !this._instance.containerNode)
throw new Error("Widget doesn't support adding children");
dom.place(this.getChildDom(child), this._instance.containerNode);
}
_create(attrs: object, children: any[]) {
cin
Support for Function Components...
r34 this._instance = new this.widgetClass(attrs);
cin
sync
r7 if (children)
children.forEach(x => this._addChild(x));
}
cin
Added DjxFragment...
r19 _getDomNode() {
cin
sync
r7 if (!this._instance)
throw new Error("The instance of the widget isn't created");
return this._instance.domNode;
}
}