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 { 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; } }