##// END OF EJS Templates
Added tag v1.8.0 for changeset 66546e709732
Added tag v1.8.0 for changeset 66546e709732

File last commit:

r109:4a375b9c654a default
r130:5811271fa858 default
Show More
FunctionRendition.ts
30 lines | 922 B | video/mp2t | TypeScriptLexer
/ djx / src / main / ts / tsx / FunctionRendition.ts
import { argumentNotNull } from "@implab/core-amd/safe";
import { getItemDom } from "./render";
import { RenditionBase } from "./RenditionBase";
export class FunctionRendition extends RenditionBase<Node> {
private readonly _component: (...args: unknown[]) => unknown;
private _node: Node | undefined;
constructor(component: (...args: unknown[]) => unknown) {
super();
argumentNotNull(component, "component");
this._component = component;
}
protected _create(attrs: object, children: unknown[]) {
const _attrs = attrs || {};
const _children = children.map(x => getItemDom(x));
this._node = getItemDom(
this._component.call(null, { ..._attrs, children: _children }));
}
protected _getDomNode() {
if (!this._node)
throw new Error("The instance of the widget isn't created");
return this._node;
}
}