##// END OF EJS Templates
Added tag v1.0.0-rc18 for changeset 5c6c7e16919c
Added tag v1.0.0-rc18 for changeset 5c6c7e16919c

File last commit:

r34:e8012fdf09ae 1.0.0-rc16 default
r39:b8741599097e default
Show More
HtmlElementContext.ts
38 lines | 1.0 KiB | video/mp2t | TypeScriptLexer
/ src / main / ts / tsx / HtmlElementContext.ts
import dom = require("dojo/dom-construct");
import attr = require("dojo/dom-attr");
import { argumentNotEmptyString } from "@implab/core-amd/safe";
import { BuildContextBase } from "./BuildContextBase";
export class HtmlElementContext extends BuildContextBase<HTMLElement> {
elementType: string;
_element: HTMLElement | undefined;
constructor(elementType: string) {
argumentNotEmptyString(elementType, "elementType");
super();
this.elementType = elementType;
}
_addChild(child: any): void {
if (!this._element)
throw new Error("The HTML element isn't created");
dom.place(this.getChildDom(child), this._element);
}
_create(attrs: object, children: any[]) {
this._element = dom.create(this.elementType, attrs);
if (children)
children.forEach(v => this._addChild(v));
}
_getDomNode() {
if (!this._element)
throw new Error("The HTML element isn't created");
return this._element;
}
}