diff --git a/web/static/src/ts/core/Widget.ts b/web/static/src/ts/core/Widget.ts index 7aa71c99..84848038 100644 --- a/web/static/src/ts/core/Widget.ts +++ b/web/static/src/ts/core/Widget.ts @@ -46,7 +46,7 @@ export class Widget { env: T; state: Object = {}; - props: Props | undefined; + props: Props; refs: { [key: string]: Widget | HTMLElement | undefined } = {}; //-------------------------------------------------------------------------- @@ -55,7 +55,12 @@ export class Widget { constructor(parent: Widget | T, props?: Props) { wl.push(this); - this.props = props; + + // is this a good idea? + // Pro: if props is empty, we can create easily a widget + // Con: this is not really safe + // Pro: but creating widget (by a template) is always unsafe anyway + this.props = props; let id: number; let p: Widget | null = null; if (parent instanceof Widget) { diff --git a/web/static/src/ts/widgets/notification.ts b/web/static/src/ts/widgets/notification.ts index b3a8e15f..81c4d456 100644 --- a/web/static/src/ts/widgets/notification.ts +++ b/web/static/src/ts/widgets/notification.ts @@ -19,6 +19,6 @@ export class Notification extends Widget { template = template; close() { - this.env.notifications.close(this.props!.id); + this.env.notifications.close(this.props.id); } }