##// END OF EJS Templates
Fixes in WidgetContex, added _Container.addChild support
Fixes in WidgetContex, added _Container.addChild support

File last commit:

r34:e8012fdf09ae 1.0.0-rc16 default
r38:5c6c7e16919c v1.0.0-rc18 default
Show More
FunctionComponentContext.ts
32 lines | 912 B | video/mp2t | TypeScriptLexer
/ src / main / ts / tsx / FunctionComponentContext.ts
cin
Support for Function Components...
r34 import dom = require("dojo/dom-construct");
import attr = require("dojo/dom-attr");
import { argumentNotNull } from "@implab/core-amd/safe";
import { BuildContextBase } from "./BuildContextBase";
export class FunctionComponentContext extends BuildContextBase<Element> {
private _component: (props: any) => Element;
private _element: Element | undefined;
constructor(component: (props: any) => Element) {
super();
argumentNotNull(component, "component");
this._component = component;
}
_create(attrs: object, children: any[]) {
const _attrs: any = attrs || {};
_attrs.children = children.map(x => this.getChildDom(x));
this._element = this._component.call(null, _attrs);
}
_getDomNode() {
if (!this._element)
throw new Error("The instance of the widget isn't created");
return this._element;
}
}