##// END OF EJS Templates
refactoring, adding scope to rendering methods
refactoring, adding scope to rendering methods

File last commit:

r96:a316cfea8bb1 v1.3
r96:a316cfea8bb1 v1.3
Show More
FunctionRendition.ts
33 lines | 984 B | video/mp2t | TypeScriptLexer
/ djx / src / main / ts / tsx / FunctionRendition.ts
import { argumentNotNull } from "@implab/core-amd/safe";
import { getItemDom } from "./Renderer";
import { RenditionBase } from "./RenditionBase";
import { IScope } from "./Scope";
export class FunctionRendition extends RenditionBase<Node> {
private _component: (...args: any[]) => any;
private _node: Node | undefined;
constructor(component: (...args: any[]) => any) {
super();
argumentNotNull(component, "component");
this._component = component;
}
protected _create(attrs: object, children: any[], scope: IScope) {
const _attrs: any = attrs || {};
const _children = children.map(x => getItemDom(x, scope));
this._node = getItemDom(
this._component.call(null, { ..._attrs, children: _children }),
scope
);
}
protected _getDomNode() {
if (!this._node)
throw new Error("The instance of the widget isn't created");
return this._node;
}
}