diff --git a/src/iframeResizer.js b/src/iframeResizer.js index 4ea1d309a..754a2a78e 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', @@ -729,6 +730,10 @@ chkEvent(iframeId, 'onClosed', iframeId) log(iframeId, '--') removeIframeListeners(iframe) + if (destroyObserver) { + destroyObserver.disconnect() + destroyObserver = null + } } function getPagePosition(iframeId) { @@ -1130,7 +1135,7 @@ function createDestroyObserver(MutationObserver) { if (!iframe.parentNode) { - return + return null } var destroyObserver = new MutationObserver(function (mutations) { @@ -1146,11 +1151,12 @@ destroyObserver.observe(iframe.parentNode, { childList: true }) + return destroyObserver } var MutationObserver = getMutationObserver() if (MutationObserver) { - createDestroyObserver(MutationObserver) + destroyObserver = createDestroyObserver(MutationObserver) } addEventListener(iframe, 'load', iFrameLoaded)