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;
|
env: T;
|
||||||
state: Object = {};
|
state: Object = {};
|
||||||
props: Props | undefined;
|
props: Props;
|
||||||
refs: { [key: string]: Widget<T, {}> | HTMLElement | undefined } = {};
|
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) {
|
constructor(parent: Widget<T, {}> | T, props?: Props) {
|
||||||
wl.push(this);
|
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 id: number;
|
||||||
let p: Widget<T, any> | null = null;
|
let p: Widget<T, any> | null = null;
|
||||||
if (parent instanceof Widget) {
|
if (parent instanceof Widget) {
|
||||||
|
|||||||
@@ -19,6 +19,6 @@ export class Notification extends Widget<Env, INotification> {
|
|||||||
template = template;
|
template = template;
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
this.env.notifications.close(this.props!.id);
|
this.env.notifications.close(this.props.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user