##// END OF EJS Templates
fixes to css, nls to support requirejs optimizer
fixes to css, nls to support requirejs optimizer

File last commit:

r34:e8012fdf09ae 1.0.0-rc16 default
r36:a1a1ef050ecc 1.0.0-rc17 default
Show More
BuildContextBase.ts
68 lines | 1.8 KiB | video/mp2t | TypeScriptLexer
/ src / main / ts / tsx / BuildContextBase.ts
cin
Added DjxFragment...
r19 import { isNull, mixin } from "@implab/core-amd/safe";
cin
Added placeAt() method to BuildContext
r14 import { isPlainObject, isNode, isBuildContext, DojoNodePosition, BuildContext } from "./traits";
cin
sync
r7
cin
Added placeAt() method to BuildContext
r14 import dom = require("dojo/dom-construct");
cin
Switched to dojo-typings...
r22 export abstract class BuildContextBase<TNode extends Node> implements BuildContext<TNode> {
cin
Support for Function Components...
r34 private _attrs = {};
cin
sync
r7
cin
Support for Function Components...
r34 private _children = new Array();
cin
sync
r7
cin
Support for Function Components...
r34 private _created: boolean = false;
cin
sync
r7
visitNext(v: any) {
cin
Support for Function Components...
r34 if (this._created)
throw new Error("The Element is already created");
cin
sync
r7 if (isNull(v))
return;
if (isPlainObject(v)) {
cin
Support for Function Components...
r34 mixin(this._attrs, v);
cin
tsx: Added auto unfolding arrays of children when constructing DOM
r13 } else if (v instanceof Array) {
cin
Support for Function Components...
r34 v.forEach(x => this.visitNext(x));
cin
sync
r7 } else {
cin
Support for Function Components...
r34 this._children.push(v);
cin
sync
r7 }
}
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)) {
cin
Added DjxFragment...
r19 return v.getDomNode();
cin
sync
r7 } else {
throw new Error("Invalid parameter");
}
}
cin
Switched to dojo-typings...
r22 abstract _getDomNode(): TNode;
cin
sync
r7
ensureCreated() {
if (!this._created) {
this._create(this._attrs, this._children);
this._children = [];
this._attrs = {};
this._created = true;
}
}
cin
Added DjxFragment...
r19 /** @deprecated use getDomNode() */
cin
sync
r7 getDomElement() {
cin
Added DjxFragment...
r19 return this.getDomNode();
}
getDomNode() {
cin
sync
r7 this.ensureCreated();
cin
Added DjxFragment...
r19 return this._getDomNode();
cin
sync
r7 }
cin
Added placeAt() method to BuildContext
r14 placeAt(refNode: string | Node, position?: DojoNodePosition) {
cin
Added DjxFragment...
r19 dom.place(this.getDomNode(), refNode, position);
cin
Added placeAt() method to BuildContext
r14 }
cin
sync
r7 abstract _create(attrs: object, children: any[]): void;
}