Skip to content

Commit

Permalink
fix: cleanup iframe first to prevent memory leaks, see niklasvh#1609
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyuyzl committed Sep 6, 2022
1 parent 6020386 commit 485a49e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/dom/document-cloner.ts
Expand Up @@ -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;
Expand Down

0 comments on commit 485a49e

Please sign in to comment.