Skip to content

Commit

Permalink
see pr: niklasvh#2949
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 96cc89a
Author: yuyuyzl <yuzhongliang221@gmail.com>
Date:   Tue Sep 6 10:36:07 2022 +0800

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

commit 485a49e
Author: yuyuyzl <yuzhongliang221@gmail.com>
Date:   Tue Sep 6 10:28:22 2022 +0800

    fix: cleanup iframe first to prevent memory leaks, see niklasvh#1609
  • Loading branch information
nangelina committed Feb 9, 2024
1 parent ebf339f commit 70e8d7f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/dom/document-cloner.ts
Expand Up @@ -489,6 +489,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 70e8d7f

Please sign in to comment.