HtmlElementContext.ts
39 lines
| 1.1 KiB
| video/mp2t
|
TypeScriptLexer
cin
|
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
|
r48 | import registry = require("dijit/registry"); | ||
cin
|
r7 | |||
cin
|
r22 | export class HtmlElementContext extends BuildContextBase<HTMLElement> { | ||
cin
|
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); | ||||
} | ||||
_create(attrs: object, children: any[]) { | ||||
this._element = dom.create(this.elementType, attrs); | ||||
if (children) | ||||
children.forEach(v => this._addChild(v)); | ||||
} | ||||
cin
|
r19 | _getDomNode() { | ||
cin
|
r7 | if (!this._element) | ||
throw new Error("The HTML element isn't created"); | ||||
return this._element; | ||||
} | ||||
} | ||||