HtmlRendition.ts
36 lines
| 958 B
| video/mp2t
|
TypeScriptLexer
cin
|
r65 | import dom = require("dojo/dom-construct"); | ||
import { argumentNotEmptyString } from "@implab/core-amd/safe"; | ||||
import { RenditionBase } from "./RenditionBase"; | ||||
export class HtmlRendition extends RenditionBase<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.getItemDom(child), this._element); | ||||
} | ||||
_create(attrs: object, children: any[]) { | ||||
this._element = dom.create(this.elementType, attrs); | ||||
cin
|
r93 | children.forEach(v => this._addChild(v)); | ||
cin
|
r65 | } | ||
_getDomNode() { | ||||
if (!this._element) | ||||
throw new Error("The HTML element isn't created"); | ||||
return this._element; | ||||
} | ||||
} | ||||