diff --git a/djx/src/main/ts/tsx/DjxWidgetBase.ts b/djx/src/main/ts/tsx/DjxWidgetBase.ts --- a/djx/src/main/ts/tsx/DjxWidgetBase.ts +++ b/djx/src/main/ts/tsx/DjxWidgetBase.ts @@ -1,4 +1,4 @@ -import { djbase, djclass } from "../declare"; +import { djbase, djclass, prototype } from "../declare"; import _WidgetBase = require("dijit/_WidgetBase"); import _AttachMixin = require("dijit/_AttachMixin"); import { Rendition, isNode } from "./traits"; @@ -21,6 +21,16 @@ export interface DjxWidgetBase; } type _super = { @@ -30,14 +40,6 @@ type _super = { @djclass export abstract class DjxWidgetBase extends djbase<_super, _AttachMixin>(_WidgetBase, _AttachMixin) { - /** The list of pairs of event and method names. When the widget is created all methods from - * this list will be connected to corresponding events. - */ - _eventHandlers: Array<{ - eventName: string, - handlerMethod: keyof any; - }> = []; - buildRendering() { this.domNode = this.render().getDomNode(); super.buildRendering(); diff --git a/djx/src/main/ts/tsx/traits.ts b/djx/src/main/ts/tsx/traits.ts --- a/djx/src/main/ts/tsx/traits.ts +++ b/djx/src/main/ts/tsx/traits.ts @@ -223,5 +223,8 @@ export const on = (eve key: K, _descriptor: TypedPropertyDescriptor<(eventObj: EV) => void> | TypedPropertyDescriptor<() => void> ): any => { - target._eventHandlers.push({ eventName, handlerMethod: key }); + if(!target._eventHandlers) + target._eventHandlers = [{ eventName, handlerMethod: key }]; + else + target._eventHandlers.push({ eventName, handlerMethod: key }); };