##// END OF EJS Templates
Initial commit, copied files related to .tsx scripts support.
Initial commit, copied files related to .tsx scripts support.

File last commit:

r0:8e944df97a68 default
r0:8e944df97a68 default
Show More
DjxWidgetBase.ts
44 lines | 1.7 KiB | video/mp2t | TypeScriptLexer
/ src / main / ts / djx / DjxWidgetBase.ts
import { djbase, djclass } from "../declare";
import _WidgetBase = require("dijit/_WidgetBase");
import _AttachMixin = require("dijit/_AttachMixin");
import { BuildContext, isNode } from "./traits";
import registry = require("dijit/registry");
@djclass
export abstract class DjxWidgetBase extends djbase(_WidgetBase, _AttachMixin) {
buildRendering() {
this.domNode = this.render().getDomElement();
super.buildRendering();
}
abstract render(): BuildContext;
_processTemplateNode<T extends (Element | Node | _WidgetBase)>(
baseNode: T,
getAttrFunc: (baseNode: T, attr: string) => string,
attachFunc: (node: T, type: string, func?: (...args: any[]) => any) => dojo.Handle
): boolean {
if (isNode(baseNode)) {
const w = registry.byNode(baseNode);
if (w) {
// from dijit/_WidgetsInTemplateMixin
this._processTemplateNode(w,
(n, p) => n[p], // callback to get a property of a widget
(widget, type, callback) => {
// callback to do data-dojo-attach-event to a widget
if (type in widget) {
// back-compat, remove for 2.0
return widget.connect(widget, type, callback);
} else {
// 1.x may never hit this branch, but it's the default for 2.0
return widget.on(type, callback);
}
});
// don't process widgets internals
return false;
}
}
return super._processTemplateNode(baseNode, getAttrFunc, attachFunc);
}
}