From 96cc89a27dbd35efb3e3373fb87c3964edd41b71 Mon Sep 17 00:00:00 2001 From: yuyuyzl Date: Tue, 6 Sep 2022 10:36:07 +0800 Subject: [PATCH] fix: cleanup iframe first to prevent memory leaks, see #1609 --- src/dom/document-cloner.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dom/document-cloner.ts b/src/dom/document-cloner.ts index 7f4864a..58a9d4d 100644 --- a/src/dom/document-cloner.ts +++ b/src/dom/document-cloner.ts @@ -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;