common: modify Component#render to properly do what it is supposed to - modify the original instance

This commit is contained in:
David Sevilla Martin 2020-03-01 15:14:00 -05:00
parent 68c17f2c30
commit 3bf7f6f85b
No known key found for this signature in database
GPG Key ID: F764F1417E16B15F

View File

@ -14,7 +14,7 @@ export default class Component<T extends ComponentProps = any> {
props: T;
constructor(props: T = <T>{}) {
this.props = props;
this.props = props.tag ? <T>{} : props;
}
view(vnode) {
@ -65,7 +65,18 @@ export default class Component<T extends ComponentProps = any> {
}
render() {
return m(this, this.props);
return m.fragment(
{
...this.props,
oninit: (...args) => this.oninit(...args),
oncreate: (...args) => this.oncreate(...args),
onbeforeupdate: (...args) => this.onbeforeupdate(...args),
onupdate: (...args) => this.onupdate.bind(...args),
onbeforeremove: (...args) => this.onbeforeremove.bind(...args),
onremove: (...args) => this.onremove.bind(...args),
},
this.view()
);
}
static component(props: ComponentProps | any = {}, children?: Mithril.Children) {