Skip to content

Commit 70e8d7f

Browse files
committed
see pr: niklasvh#2949
Squashed commit of the following: commit 96cc89a Author: yuyuyzl <[email protected]> Date: Tue Sep 6 10:36:07 2022 +0800 fix: cleanup iframe first to prevent memory leaks, see niklasvh#1609 commit 485a49e Author: yuyuyzl <[email protected]> Date: Tue Sep 6 10:28:22 2022 +0800 fix: cleanup iframe first to prevent memory leaks, see niklasvh#1609
1 parent ebf339f commit 70e8d7f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/dom/document-cloner.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,16 @@ export class DocumentCloner {
489489
}
490490

491491
static destroy(container: HTMLIFrameElement): boolean {
492+
// cleanup iframe first to prevent memory leaks, see #1609
493+
try {
494+
const iframe = container.contentWindow;
495+
container.src = 'about:blank';
496+
if (iframe) {
497+
iframe.document.write('');
498+
iframe.document.clear();
499+
iframe.close();
500+
}
501+
} catch {}
492502
if (container.parentNode) {
493503
container.parentNode.removeChild(container);
494504
return true;

0 commit comments

Comments
 (0)