##// END OF EJS Templates
Added playground project
Added playground project

File last commit:

r96:a316cfea8bb1 v1.3
r97:8b413dc7fc42 v1.3
Show More
HtmlRendition.ts
39 lines | 1.1 KiB | video/mp2t | TypeScriptLexer
/ djx / src / main / ts / tsx / HtmlRendition.ts
import dom = require("dojo/dom-construct");
import { argumentNotEmptyString } from "@implab/core-amd/safe";
import { RenditionBase } from "./RenditionBase";
import { placeAt } from "./traits";
import { IScope } from "./Scope";
import { getItemDom } from "./Renderer";
export class HtmlRendition extends RenditionBase<HTMLElement> {
elementType: string;
_element: HTMLElement | undefined;
constructor(elementType: string) {
argumentNotEmptyString(elementType, "elementType");
super();
this.elementType = elementType;
}
_addChild(child: unknown, scope: IScope): void {
if (!this._element)
throw new Error("The HTML element isn't created");
placeAt(getItemDom(child, scope), this._element);
}
_create(attrs: object, children: unknown[], scope: IScope) {
this._element = dom.create(this.elementType, attrs);
children.forEach(v => this._addChild(v, scope));
}
_getDomNode() {
if (!this._element)
throw new Error("The HTML element isn't created");
return this._element;
}
}