From 1d10784a09ba65cc2b7e56d770e5c3ff9046ebb1 Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Thu, 31 Mar 2016 15:28:37 -0400 Subject: [PATCH] Simplify logic for when a webview needs to be added From a screenshot on #browser, Serg seems to have gotten in a staste where the webview wasn't added to the dom yet, or possibly it was because the dom wasn't ready yet. Anyway I'd like to rule this out in case a child node isn't removed immediately Auditors: @diracdeltas --- js/components/frame.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js/components/frame.js b/js/components/frame.js index d322d591c6d..da85565fe6c 100644 --- a/js/components/frame.js +++ b/js/components/frame.js @@ -56,12 +56,14 @@ class Frame extends ImmutableComponent { // Create the webview dynamically because React doesn't whitelist all // of the attributes we need. Clear out old webviews if the contentScripts change or if // allowRunningInsecureContent changes because they cannot change after being added to the DOM. + let webviewAdded = false if (!this.webview || this.webview.allowRunningInsecureContent !== allowRunningInsecureContent || contentScriptsChanged) { while (this.webviewContainer.firstChild) { this.webviewContainer.removeChild(this.webviewContainer.firstChild) } this.webview = document.createElement('webview') src = location + webviewAdded = true } this.webview.setAttribute('allowDisplayingInsecureContent', true) this.webview.setAttribute('data-frame-key', this.props.frame.get('key')) @@ -98,7 +100,7 @@ class Frame extends ImmutableComponent { } this.webview.setAttribute('src', isSourceAboutUrl(src) ? getTargetAboutUrl(src) : src) - if (!this.webviewContainer.firstChild) { + if (webviewAdded) { this.webviewContainer.appendChild(this.webview) this.addEventListeners() }