mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
fix(core): node销毁后重新渲染再销毁不会触发destroy事件
This commit is contained in:
parent
cda3b04b85
commit
a8eea1a73b
@ -54,15 +54,6 @@ class Node extends EventEmitter {
|
|||||||
this.data = options.config;
|
this.data = options.config;
|
||||||
this.events = events || [];
|
this.events = events || [];
|
||||||
this.listenLifeSafe();
|
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) {
|
public setData(data: MComponent | MContainer | MPage) {
|
||||||
@ -76,6 +67,15 @@ class Node extends EventEmitter {
|
|||||||
|
|
||||||
private listenLifeSafe() {
|
private listenLifeSafe() {
|
||||||
this.once('created', async (instance: any) => {
|
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;
|
this.instance = instance;
|
||||||
await this.runCodeBlock('created');
|
await this.runCodeBlock('created');
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user