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 485a49e commit 96cc89a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/dom/document-cloner.ts
Expand Up @@ -480,15 +480,15 @@ 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) {
try {
const iframe = container.contentWindow;
container.src = 'about:blank';
if (iframe) {
iframe.document.write('');
iframe.document.clear();
iframe.close();
}
}catch {}
} catch {}
if (container.parentNode) {
container.parentNode.removeChild(container);
return true;
Expand Down

0 comments on commit 96cc89a

Please sign in to comment.