mirror of
https://github.com/flarum/framework.git
synced 2025-01-22 08:52:34 +08:00
common: modify Component#render to properly do what it is supposed to - modify the original instance
This commit is contained in:
parent
68c17f2c30
commit
3bf7f6f85b
|
@ -14,7 +14,7 @@ export default class Component<T extends ComponentProps = any> {
|
||||||
props: T;
|
props: T;
|
||||||
|
|
||||||
constructor(props: T = <T>{}) {
|
constructor(props: T = <T>{}) {
|
||||||
this.props = props;
|
this.props = props.tag ? <T>{} : props;
|
||||||
}
|
}
|
||||||
|
|
||||||
view(vnode) {
|
view(vnode) {
|
||||||
|
@ -65,7 +65,18 @@ export default class Component<T extends ComponentProps = any> {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
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) {
|
static component(props: ComponentProps | any = {}, children?: Mithril.Children) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user