fix: cleanup iframe first to prevent memory leaks, see #1609

This commit is contained in:
yuyuyzl 2022-09-06 10:28:22 +08:00
parent 6020386bbe
commit 485a49e451

View File

@ -479,6 +479,16 @@ export class DocumentCloner {
}
static destroy(container: HTMLIFrameElement): boolean {
// cleanup iframe first to prevent memory leaks, see #1609
try{
const iframe=container.contentWindow;
container.src='about:blank';
if(iframe) {
iframe.document.write('');
iframe.document.clear();
iframe.close();
}
}catch {}
if (container.parentNode) {
container.parentNode.removeChild(container);
return true;