Guard against attachedCallback firing while handling detachedCallback
authorKevin Sawicki <kevinsawicki@gmail.com>
Thu, 3 Nov 2016 00:28:37 +0000 (17:28 -0700)
committerKevin Sawicki <kevinsawicki@gmail.com>
Mon, 7 Nov 2016 21:42:36 +0000 (13:42 -0800)
lib/renderer/web-view/web-view.js

index fc8b9a4..27cb07f 100644 (file)
@@ -72,9 +72,12 @@ class WebViewImpl {
     }
 
     this.webContents = null
-    this.attributes[webViewConstants.ATTRIBUTE_GUESTINSTANCE].setValueIgnoreMutation(undefined)
     this.beforeFirstNavigation = true
     this.attributes[webViewConstants.ATTRIBUTE_PARTITION].validPartitionId = true
+
+    // Set guestinstance last since this can trigger the attachedCallback to fire
+    // when moving the webview using element.replaceChild
+    this.attributes[webViewConstants.ATTRIBUTE_GUESTINSTANCE].setValueIgnoreMutation(undefined)
   }
 
   // Sets the <webview>.request property.
@@ -310,8 +313,8 @@ var registerWebViewElement = function () {
     }
     guestViewInternal.deregisterEvents(internal.viewInstanceId)
     internal.elementAttached = false
-    internal.reset()
     this.internalInstanceId = 0
+    internal.reset()
   }
   proto.attachedCallback = function () {
     var internal, instance