##// END OF EJS Templates
Added 'Attrs', 'Events' type parameters to DjxWidgetBase, typed 'on' and 'emit' methods
Added 'Attrs', 'Events' type parameters to DjxWidgetBase, typed 'on' and 'emit' methods

File last commit:

r22:a1ab2b5975ad v1.0.0-rc10 default
r30:a46488b209e8 v1.0.0-rc14 default
Show More
HtmlElementContext.ts
45 lines | 1.2 KiB | video/mp2t | TypeScriptLexer
/ src / main / ts / tsx / HtmlElementContext.ts
cin
sync
r7 import dom = require("dojo/dom-construct");
import attr = require("dojo/dom-attr");
import { argumentNotEmptyString } from "@implab/core-amd/safe";
import { BuildContextBase } from "./BuildContextBase";
cin
Switched to dojo-typings...
r22 export class HtmlElementContext extends BuildContextBase<HTMLElement> {
cin
sync
r7 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));
}
cin
Added DjxFragment...
r19 _getDomNode() {
cin
sync
r7 if (!this._element)
throw new Error("The HTML element isn't created");
return this._element;
}
}