##// END OF EJS Templates
`Subscribable` is made compatible with rxjs, added map, filter and scan...
`Subscribable` is made compatible with rxjs, added map, filter and scan methods to observables. `watch` can accept either stateful object and a property name to observe or the subscribable value. added ref attribute to the markup elements and widgets. `bind`, `tooggleClass` and `attach` methods can be passed to `ref` attribute in the markup to interact with elemnts and widgets.

File last commit:

r102:c65ea2350b1a v1.3
r102:c65ea2350b1a v1.3
Show More
HtmlRendition.ts
50 lines | 1.4 KiB | video/mp2t | TypeScriptLexer
/ djx / src / main / ts / tsx / HtmlRendition.ts
import djDom = require("dojo/dom-construct");
import djAttr = require("dojo/dom-attr");
import { argumentNotEmptyString } from "@implab/core-amd/safe";
import { RenditionBase } from "./RenditionBase";
import { placeAt } from "./traits";
import { getItemDom, refHook } from "./render";
export class HtmlRendition extends RenditionBase<Element> {
elementType: string;
_element: Element | undefined;
constructor(elementType: string) {
argumentNotEmptyString(elementType, "elementType");
super();
this.elementType = elementType;
}
_addChild(child: unknown): void {
if (!this._element)
throw new Error("The HTML element isn't created");
placeAt(getItemDom(child), this._element);
}
_create({ xmlns, ref, ...attrs }: { xmlns?: string, ref?: JSX.Ref<Element> }, children: unknown[]) {
if (xmlns) {
this._element = document.createElementNS(xmlns, this.elementType);
djAttr.set(this._element, attrs);
} else {
this._element = djDom.create(this.elementType, attrs);
}
children.forEach(v => this._addChild(v));
const element = this._element;
if (ref)
refHook(element, ref);
}
_getDomNode() {
if (!this._element)
throw new Error("The HTML element isn't created");
return this._element;
}
}