##// END OF EJS Templates
Added tag v1.7.0 for changeset cede47727a1b
Added tag v1.7.0 for changeset cede47727a1b

File last commit:

r109:4a375b9c654a default
r126:57b65a506e4f 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;
}
}