fix: create WebContents for webview on request (#13713)

This commit is contained in:
Cheng Zhao 2018-07-21 11:11:28 +09:00 committed by GitHub
parent 014832237c
commit 9d6f1a372e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 8 deletions

View file

@ -174,6 +174,10 @@ class WebViewImpl {
})
}
createGuestSync () {
this.attachGuestInstance(guestViewInternal.createGuestSync(this.buildParams()))
}
dispatchEvent (webViewEvent) {
this.webviewNode.dispatchEvent(webViewEvent)
}
@ -422,7 +426,11 @@ const registerWebViewElement = function () {
// WebContents associated with this webview.
proto.getWebContents = function () {
return v8Util.getHiddenValue(this, 'internal').webContents
const internal = v8Util.getHiddenValue(this, 'internal')
if (!internal.webContents) {
internal.createGuestSync()
}
return internal.webContents
}
window.WebView = webFrame.registerEmbedderCustomElement('webview', {