mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-06-11 14:45:10 +08:00
fix(stage): render destroy后移除load事件
This commit is contained in:
parent
504adcb017
commit
f03281ac6c
@ -52,15 +52,7 @@ export default class StageRender extends EventEmitter {
|
||||
height: 100%;
|
||||
`;
|
||||
|
||||
this.iframe.onload = async () => {
|
||||
this.emit('onload');
|
||||
if (this.render) {
|
||||
const el = await this.render(this.core);
|
||||
if (el) {
|
||||
this.iframe?.contentDocument?.body?.appendChild(el);
|
||||
}
|
||||
}
|
||||
};
|
||||
this.iframe.addEventListener('load', this.loadHandler);
|
||||
}
|
||||
|
||||
public getMagicApi = () => ({
|
||||
@ -113,9 +105,20 @@ export default class StageRender extends EventEmitter {
|
||||
* 销毁实例
|
||||
*/
|
||||
public destroy(): void {
|
||||
this.iframe?.removeEventListener('load', this.loadHandler);
|
||||
this.contentWindow = null;
|
||||
this.iframe?.remove();
|
||||
this.iframe = undefined;
|
||||
this.removeAllListeners();
|
||||
}
|
||||
|
||||
private loadHandler = async () => {
|
||||
this.emit('onload');
|
||||
if (this.render) {
|
||||
const el = await this.render(this.core);
|
||||
if (el) {
|
||||
this.iframe?.contentDocument?.body?.appendChild(el);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user