From b6f7fb6834b021ba2912e251c1bde304dd6a11f5 Mon Sep 17 00:00:00 2001 From: StevenHong Date: Thu, 11 Apr 2024 01:20:32 +0800 Subject: [PATCH 1/3] fix close release destroyObserver --- src/iframeResizer.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/iframeResizer.js b/src/iframeResizer.js index 4ea1d309a..d413c8c41 100644 --- a/src/iframeResizer.js +++ b/src/iframeResizer.js @@ -68,7 +68,8 @@ onScroll: function () { return true } - }) + }), + destroyObserver function getMutationObserver() { return ( @@ -729,6 +730,8 @@ chkEvent(iframeId, 'onClosed', iframeId) log(iframeId, '--') removeIframeListeners(iframe) + destroyObserver && destroyObserver.disconnect() + destroyObserver = null } function getPagePosition(iframeId) { @@ -1146,11 +1149,12 @@ destroyObserver.observe(iframe.parentNode, { childList: true }) + return destroyObserver } var MutationObserver = getMutationObserver() if (MutationObserver) { - createDestroyObserver(MutationObserver) + destroyObserver = createDestroyObserver(MutationObserver) } addEventListener(iframe, 'load', iFrameLoaded) From 6c3b622c9f8bad0be77bd4811cb2e9033d526afa Mon Sep 17 00:00:00 2001 From: Steven Date: Mon, 15 Apr 2024 09:22:02 +0800 Subject: [PATCH 2/3] chore: reorder by alphabetical --- src/iframeResizer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/iframeResizer.js b/src/iframeResizer.js index d413c8c41..0a83bc319 100644 --- a/src/iframeResizer.js +++ b/src/iframeResizer.js @@ -13,6 +13,7 @@ if (typeof window === 'undefined') return // don't run for server side render var count = 0, + destroyObserver, logEnabled = false, hiddenCheckEnabled = false, msgHeader = 'message', @@ -68,8 +69,7 @@ onScroll: function () { return true } - }), - destroyObserver + }) function getMutationObserver() { return ( From 0e3824e1941184ad74a4b0e2bf76c82cec811301 Mon Sep 17 00:00:00 2001 From: StevenHong Date: Tue, 16 Apr 2024 22:47:00 +0800 Subject: [PATCH 3/3] eslint fix --- src/iframeResizer.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/iframeResizer.js b/src/iframeResizer.js index 0a83bc319..754a2a78e 100644 --- a/src/iframeResizer.js +++ b/src/iframeResizer.js @@ -730,8 +730,10 @@ chkEvent(iframeId, 'onClosed', iframeId) log(iframeId, '--') removeIframeListeners(iframe) - destroyObserver && destroyObserver.disconnect() - destroyObserver = null + if (destroyObserver) { + destroyObserver.disconnect() + destroyObserver = null + } } function getPagePosition(iframeId) { @@ -1133,7 +1135,7 @@ function createDestroyObserver(MutationObserver) { if (!iframe.parentNode) { - return + return null } var destroyObserver = new MutationObserver(function (mutations) {