##// END OF EJS Templates
typescript strict mode...
typescript strict mode Added TAP traits, TAP text writer

File last commit:

r1:b6ccfccf314f default
r1:b6ccfccf314f default
Show More
BuildContextBase.ts
64 lines | 1.6 KiB | video/mp2t | TypeScriptLexer
/ src / main / ts / djx / BuildContextBase.ts
cin
typescript strict mode...
r1 import { isNull, mixin, argumentNotNull } from "@implab/core-amd/safe";
cin
Initial commit, copied files related to .tsx scripts support.
r0 import { isPlainObject, isNode, isBuildContext } from "./traits";
export abstract class BuildContextBase {
_attrs = {};
cin
typescript strict mode...
r1 _children = new Array();
cin
Initial commit, copied files related to .tsx scripts support.
r0
cin
typescript strict mode...
r1 _created: boolean = false;
cin
Initial commit, copied files related to .tsx scripts support.
r0
visitNext(v: any) {
if (isNull(v))
return;
if (isPlainObject(v)) {
if (this._created)
this._setAttrs(v);
else
mixin(this._attrs, v);
} else {
if (this._created)
this._addChild(v);
else
this._children.push(v);
}
}
getChildDom(v: any) {
const tv = typeof v;
if (tv === "string" || tv === "number" || tv === "boolean" || v instanceof RegExp || v instanceof Date) {
return document.createTextNode(v.toString());
} else if (isNode(v)) {
return v;
} else if (isBuildContext(v)) {
return v.getDomElement();
} else {
throw new Error("Invalid parameter");
}
}
abstract _getDomElement(): HTMLElement;
ensureCreated() {
if (!this._created) {
this._create(this._attrs, this._children);
cin
typescript strict mode...
r1 this._children = [];
this._attrs = {};
cin
Initial commit, copied files related to .tsx scripts support.
r0 this._created = true;
}
}
getDomElement() {
this.ensureCreated();
return this._getDomElement();
}
abstract _addChild(child: any): void;
abstract _setAttrs(attrs: object): void;
abstract _create(attrs: object, children: any[]): void;
}