##// END OF EJS Templates
* tsx/{Xxx}Context renamed to tsx/{Xxx}Rendition, for old types made...
* tsx/{Xxx}Context renamed to tsx/{Xxx}Rendition, for old types made compatibility stubs with @deprected comments * Improved handling of functional component output, added support for boolean, null, undefined and widgets. * RenditionBase: fixed startup for the DocumentFragment nodes * startupWidgets: fixed startup of the widget when passed domNode of the widget. * DjxFragment converted to the functional component

File last commit:

r63:1a0018655d1c v1.1.0 default
r63:1a0018655d1c v1.1.0 default
Show More
traits.ts
145 lines | 4.2 KiB | video/mp2t | TypeScriptLexer
cin
Fixed startup of DjxWidgetBase to start inner widgets...
r52 import { IDestroyable } from "@implab/core-amd/interfaces";
import { isDestroyable } from "@implab/core-amd/safe";
cin
sync
r7 import _WidgetBase = require("dijit/_WidgetBase");
cin
Fixed startup of DjxWidgetBase to start inner widgets...
r52 import registry = require("dijit/registry");
import dom = require("dojo/dom-construct");
cin
sync
r7
type _WidgetBaseConstructor = typeof _WidgetBase;
cin
Added placeAt() method to BuildContext
r14 export type DojoNodePosition = "first" | "after" | "before" | "last" | "replace" | "only" | number;
cin
sync
r7
cin
* tsx/{Xxx}Context renamed to tsx/{Xxx}Rendition, for old types made...
r63 export interface Rendition<TNode extends Node = Node> {
cin
Switched to dojo-typings...
r22 getDomNode(): TNode;
cin
Added placeAt() method to BuildContext
r14
placeAt(refNode: string | Node, position?: DojoNodePosition): void;
cin
sync
r7 }
cin
* tsx/{Xxx}Context renamed to tsx/{Xxx}Rendition, for old types made...
r63 /**
* @deprecated use Rendition
*/
export type BuildContext<TNode extends Node = Node> = Rendition<TNode>;
cin
Fixed startup of DjxWidgetBase to start inner widgets...
r52 export interface IRecursivelyDestroyable {
destroyRecursive(): void;
}
cin
Added DjxFragment...
r19 export function isNode(el: any): el is Node {
cin
sync
r7 return el && el.nodeName && el.nodeType;
}
cin
Added DjxFragment...
r19 export function isElementNode(el: any): el is Element {
return isNode(el) && el.nodeType === 1;
}
export function isTextNode(el: any): el is Text {
return isNode(el) && el.nodeType === 3;
}
export function isProcessingInstructionNode(el: any): el is ProcessingInstruction {
return isNode(el) && el.nodeType === 7;
}
export function isCommentNode(el: any): el is Comment {
return isNode(el) && el.nodeType === 8;
}
export function isDocumentNode(el: any): el is Document {
return isNode(el) && el.nodeType === 9;
}
export function isDocumentTypeNode(el: any): el is DocumentType {
return isNode(el) && el.nodeType === 10;
}
export function isDocumentFragmentNode(el: any): el is DocumentFragment {
return isNode(el) && el.nodeType === 11;
}
cin
sync
r7 export function isWidget(v: any): v is _WidgetBase {
return v && "domNode" in v;
}
cin
* tsx/{Xxx}Context renamed to tsx/{Xxx}Rendition, for old types made...
r63 export function isRendition(v: any): v is Rendition {
cin
sync
r7 return typeof v === "object" && typeof v.getDomElement === "function";
}
cin
* tsx/{Xxx}Context renamed to tsx/{Xxx}Rendition, for old types made...
r63 /**
* @deprecated use isRendition
*/
export const isBuildContext = isRendition;
cin
sync
r7 export function isPlainObject(v: object) {
if (typeof v !== "object")
return false;
const vp = Object.getPrototypeOf(v);
return !vp || vp === Object.prototype;
}
export function isWidgetConstructor(v: any): v is _WidgetBaseConstructor {
cin
Fixes in WidgetContex, added _Container.addChild support
r38 return typeof v === "function" && v.prototype && (
"domNode" in v.prototype ||
"buildRendering" in v.prototype
);
cin
sync
r7 }
cin
Added support for ContentPane, corrected widget startup calls
r48
/** Tests whether the specified node is placed in visible dom.
* @param {Node} node The node to test
*/
export function isInPage(node: Node) {
return (node === document.body) ? false : document.body.contains(node);
}
cin
Fixed startup of DjxWidgetBase to start inner widgets...
r52
export function isRecursivelyDestroyable(target: any): target is IRecursivelyDestroyable {
return target && typeof target.destroyRecursive === "function";
}
/** Destroys DOM Node with all contained widgets.
* If the specified node is the root node of a widget, then the
* widget will be destroyed.
*
* @param target DOM Node or widget to destroy
*/
export function destroy(target: Node | IDestroyable | IRecursivelyDestroyable) {
if (isRecursivelyDestroyable(target)) {
target.destroyRecursive();
} else if (isDestroyable(target)) {
target.destroy();
} else if (isNode(target)) {
const self = registry.byNode(target);
if (self) {
self.destroyRecursive();
} else {
registry.findWidgets(target).forEach(destroy);
dom.destroy(target);
}
}
}
/** Empties a content of the specified node and destroys all contained widgets.
*
* @param target DOM node to .
*/
export function emptyNode(target: Node) {
registry.findWidgets(target).forEach(destroy);
dom.empty(target);
}
cin
* tsx/{Xxx}Context renamed to tsx/{Xxx}Rendition, for old types made...
r63 /** This function starts all widgets inside the DOM node if the target is a node
* or starts widget itself if the target is the widget. If the specified node
* associated with the widget that widget will be started.
cin
Fixed startup of DjxWidgetBase to start inner widgets...
r52 *
* @param target DOM node to find and start widgets or the widget itself.
*/
export function startupWidgets(target: Node | _WidgetBase, skipNode?: Node) {
if (isNode(target)) {
cin
* tsx/{Xxx}Context renamed to tsx/{Xxx}Rendition, for old types made...
r63 const w = registry.byNode(target);
if (w) {
w.startup && w.startup();
} else {
registry.findWidgets(target, skipNode).forEach(w => w.startup());
}
cin
Fixed startup of DjxWidgetBase to start inner widgets...
r52 } else {
cin
* tsx/{Xxx}Context renamed to tsx/{Xxx}Rendition, for old types made...
r63 target.startup && target.startup();
cin
Fixed startup of DjxWidgetBase to start inner widgets...
r52 }
}