Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix close release destroyObserver #1229

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/iframeResizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -729,6 +730,10 @@
chkEvent(iframeId, 'onClosed', iframeId)
log(iframeId, '--')
removeIframeListeners(iframe)
if (destroyObserver) {
destroyObserver.disconnect()
destroyObserver = null
}
}

function getPagePosition(iframeId) {
Expand Down Expand Up @@ -1130,7 +1135,7 @@

function createDestroyObserver(MutationObserver) {
if (!iframe.parentNode) {
return
return null
}

var destroyObserver = new MutationObserver(function (mutations) {
Expand All @@ -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)
Expand Down