Clean up WebView's ipc listeners when detached, fix #1185
This commit is contained in:
parent
5bd3cfc4f6
commit
d46c64f64b
2 changed files with 7 additions and 2 deletions
|
@ -40,6 +40,11 @@ module.exports =
|
|||
domEvent[f] = args[i]
|
||||
webView.onSizeChanged domEvent
|
||||
|
||||
deregisterEvents: (viewInstanceId) ->
|
||||
ipc.removeAllListeners "ATOM_SHELL_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-#{viewInstanceId}"
|
||||
ipc.removeAllListeners "ATOM_SHELL_GUEST_VIEW_INTERNAL_IPC_MESSAGE-#{viewInstanceId}"
|
||||
ipc.removeAllListeners "ATOM_SHELL_GUEST_VIEW_INTERNAL_SIZE_CHANGED-#{viewInstanceId}"
|
||||
|
||||
createGuest: (type, params, callback) ->
|
||||
requestId++
|
||||
ipc.send 'ATOM_SHELL_GUEST_VIEW_MANAGER_CREATE_GUEST', type, params, requestId
|
||||
|
|
|
@ -28,8 +28,6 @@ class WebViewImpl
|
|||
|
||||
@viewInstanceId = getNextId()
|
||||
|
||||
guestViewInternal.registerEvents this, @viewInstanceId
|
||||
|
||||
shadowRoot.appendChild @browserPluginNode
|
||||
|
||||
createBrowserPluginNode: ->
|
||||
|
@ -222,6 +220,7 @@ registerWebViewElement = ->
|
|||
proto.detachedCallback = ->
|
||||
internal = v8Util.getHiddenValue this, 'internal'
|
||||
return unless internal
|
||||
guestViewInternal.deregisterEvents internal.viewInstanceId
|
||||
internal.elementAttached = false
|
||||
internal.reset()
|
||||
|
||||
|
@ -229,6 +228,7 @@ registerWebViewElement = ->
|
|||
internal = v8Util.getHiddenValue this, 'internal'
|
||||
return unless internal
|
||||
unless internal.elementAttached
|
||||
guestViewInternal.registerEvents internal, internal.viewInstanceId
|
||||
internal.elementAttached = true
|
||||
internal.attributes[webViewConstants.ATTRIBUTE_SRC].parse()
|
||||
|
||||
|
|
Loading…
Reference in a new issue