mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
make props a always defined property
This commit is contained in:
@@ -46,7 +46,7 @@ export class Widget<T extends WEnv, Props> {
|
||||
|
||||
env: T;
|
||||
state: Object = {};
|
||||
props: Props | undefined;
|
||||
props: Props;
|
||||
refs: { [key: string]: Widget<T, {}> | HTMLElement | undefined } = {};
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -55,7 +55,12 @@ export class Widget<T extends WEnv, Props> {
|
||||
|
||||
constructor(parent: Widget<T, {}> | 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>props;
|
||||
let id: number;
|
||||
let p: Widget<T, any> | null = null;
|
||||
if (parent instanceof Widget) {
|
||||
|
||||
@@ -19,6 +19,6 @@ export class Notification extends Widget<Env, INotification> {
|
||||
template = template;
|
||||
|
||||
close() {
|
||||
this.env.notifications.close(this.props!.id);
|
||||
this.env.notifications.close(this.props.id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user