fix(core): node销毁后重新渲染再销毁不会触发destroy事件

This commit is contained in:
roymondchen 2023-08-31 15:47:04 +08:00
parent cda3b04b85
commit a8eea1a73b

View File

@ -54,15 +54,6 @@ class Node extends EventEmitter {
this.data = options.config;
this.events = events || [];
this.listenLifeSafe();
this.once('destroy', () => {
this.instance = null;
if (typeof this.data.destroy === 'function') {
this.data.destroy(this);
}
this.listenLifeSafe();
});
}
public setData(data: MComponent | MContainer | MPage) {
@ -76,6 +67,15 @@ class Node extends EventEmitter {
private listenLifeSafe() {
this.once('created', async (instance: any) => {
this.once('destroy', () => {
this.instance = null;
if (typeof this.data.destroy === 'function') {
this.data.destroy(this);
}
this.listenLifeSafe();
});
this.instance = instance;
await this.runCodeBlock('created');
});