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

This commit is contained in:
trop[bot] 2018-07-21 16:51:31 +09:00 committed by Cheng Zhao
commit 4333020157
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)
}
@ -421,7 +425,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', {