Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #1213 from brave/dev-channel
Browse files Browse the repository at this point in the history
Simplify logic for when a webview needs to be added
  • Loading branch information
bbondy committed Mar 31, 2016
2 parents eb96ff7 + 1d10784 commit 5fc7981
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion js/components/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down Expand Up @@ -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()
}
Expand Down

0 comments on commit 5fc7981

Please sign in to comment.