fix: print warning after DOM is created

This commit is contained in:
Cheng Zhao 2018-10-17 10:42:02 +09:00
parent 714f3ffd29
commit 8716f718a9
3 changed files with 20 additions and 2 deletions

View file

@ -54,7 +54,13 @@ BrowserWindow.prototype._init = function () {
'"nativeWindowOpen" option will cause memory leaks, please turn off ' +
'the "nodeIntegration" option.\\n' +
'See https://github.com/electron/electron/pull/15076 for more.'
this.webContents.executeJavaScript(`console.warn('${message}')`)
// console is only available after DOM is created.
const printWarning = () => this.webContents.executeJavaScript(`console.warn('${message}')`)
if (this.webContents.isDomReady()) {
printWarning()
} else {
this.webContents.once('dom-ready', printWarning)
}
}
let {url, frameName} = urlFrameName