##// END OF EJS Templates
created typings for basic part of dojo and dijit further work is required to...
created typings for basic part of dojo and dijit further work is required to complete typings and separate them from this project dojo-typings replaced with @type/dojo, @type/dijit.

File last commit:

r1:b6ccfccf314f default
r2:8ec37bf1b4d1 default
Show More
HtmlElementContext.ts
45 lines | 1.2 KiB | video/mp2t | TypeScriptLexer
/ src / main / ts / djx / 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 {
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);
}
_setAttrs(attrs: object): void {
if (!this._element)
throw new Error("The HTML element isn't created");
attr.set(this._element, attrs);
}
_create(attrs: object, children: any[]) {
this._element = dom.create(this.elementType, attrs);
if (children)
children.forEach(v => this._addChild(v));
}
_getDomElement() {
if (!this._element)
throw new Error("The HTML element isn't created");
return this._element;
}
}