##// END OF EJS Templates
added whenRendered() method to wait for pending oprations to complete
added whenRendered() method to wait for pending oprations to complete

File last commit:

r112:2ccfaae984e9 v1.4.4 default
r118:e07418577cbc v1.6.1 default
Show More
RenditionBase.ts
70 lines | 2.3 KiB | video/mp2t | TypeScriptLexer
/ djx / src / main / ts / tsx / RenditionBase.ts
cin
`Subscribable` is made compatible with rxjs, added map, filter and scan...
r102 import { isPlainObject, DojoNodePosition, Rendition, isDocumentFragmentNode, placeAt, collectNodes, isMounted, startupWidgets } from "./traits";
cin
Converted to subproject djx, removed dojo-typings
r65
export abstract class RenditionBase<TNode extends Node> implements Rendition<TNode> {
private _attrs = {};
cin
linting
r109 private _children: unknown[] = [];
cin
Converted to subproject djx, removed dojo-typings
r65
cin
linting
r109 private _created = false;
cin
Converted to subproject djx, removed dojo-typings
r65
cin
linting
r109 visitNext(v: unknown) {
cin
Converted to subproject djx, removed dojo-typings
r65 if (this._created)
throw new Error("The Element is already created");
cin
`Subscribable` is made compatible with rxjs, added map, filter and scan...
r102 if (v === null || v === undefined || typeof v === "boolean")
cin
Converted to subproject djx, removed dojo-typings
r65 // skip null, undefined, booleans ( this will work: {value && <span>{value}</span>} )
return;
if (isPlainObject(v)) {
cin
`Subscribable` is made compatible with rxjs, added map, filter and scan...
r102 this._attrs = {... this._attrs, ...v};
cin
Converted to subproject djx, removed dojo-typings
r65 } else if (v instanceof Array) {
v.forEach(x => this.visitNext(x));
} else {
this._children.push(v);
}
}
cin
`Subscribable` is made compatible with rxjs, added map, filter and scan...
r102 ensureCreated() {
cin
Converted to subproject djx, removed dojo-typings
r65 if (!this._created) {
cin
`Subscribable` is made compatible with rxjs, added map, filter and scan...
r102 this._create(this._attrs, this._children);
cin
Converted to subproject djx, removed dojo-typings
r65 this._children = [];
this._attrs = {};
this._created = true;
}
}
cin
minor code cleanups
r93 /** Is rendition was instantiated to the DOM node */
isCreated() {
return this._created;
cin
Converted to subproject djx, removed dojo-typings
r65 }
/** Creates DOM node if not created. No additional actions are taken. */
cin
`Subscribable` is made compatible with rxjs, added map, filter and scan...
r102 getDomNode() {
this.ensureCreated();
cin
Converted to subproject djx, removed dojo-typings
r65 return this._getDomNode();
}
/** Creates DOM node if not created, places it to the specified position
* and calls startup() method for all widgets contained by this node.
*
* @param {string | Node} refNode The reference node where the created
* DOM should be placed.
* @param {DojoNodePosition} position Optional parameter, specifies the
* position relative to refNode. Default is "last" (i.e. last child).
*/
cin
refactoring, adding scope to rendering methods
r96 placeAt(refNode: string | Node, position: DojoNodePosition = "last") {
cin
Converted to subproject djx, removed dojo-typings
r65 const domNode = this.getDomNode();
cin
`Subscribable` is made compatible with rxjs, added map, filter and scan...
r102 const startupPending = isDocumentFragmentNode(domNode) ? collectNodes(domNode.childNodes) : [domNode];
cin
Converted to subproject djx, removed dojo-typings
r65
cin
refactoring, adding scope to rendering methods
r96 placeAt(domNode, refNode, position);
cin
Converted to subproject djx, removed dojo-typings
r65
cin
fixed NlsBundle locale package loading...
r112 if (startupPending.length && isMounted(startupPending[0]))
cin
`Subscribable` is made compatible with rxjs, added map, filter and scan...
r102 startupPending.forEach(n => startupWidgets(n));
cin
Fixed RenditionBase.placeAt for DjxFragment
r67
cin
Converted to subproject djx, removed dojo-typings
r65 }
cin
`Subscribable` is made compatible with rxjs, added map, filter and scan...
r102 protected abstract _create(attrs: object, children: unknown[]): void;
cin
Converted to subproject djx, removed dojo-typings
r65
protected abstract _getDomNode(): TNode;
}