Add "webview-dom-ready" event

This commit is contained in:
Thomas Brouard 2020-02-28 10:33:20 +01:00
parent b866d47157
commit 4cbbdbc033
2 changed files with 8 additions and 4 deletions

View file

@ -216,6 +216,7 @@ The following events are available:
* `tabGroup.on("tab-removed", (tab, tabGroup) => { ... });` * `tabGroup.on("tab-removed", (tab, tabGroup) => { ... });`
* `tabGroup.on("tab-active", (tab, tabGroup) => { ... });` * `tabGroup.on("tab-active", (tab, tabGroup) => { ... });`
* `tab.on("webview-ready", (tab) => { ... });` * `tab.on("webview-ready", (tab) => { ... });`
* `tab.on("webview-dom-ready", (tab) => { ... });`
* `tab.on("title-changed", (title, tab) => { ... });` * `tab.on("title-changed", (title, tab) => { ... });`
* `tab.on("icon-changed", (icon, tab) => { ... });` * `tab.on("icon-changed", (icon, tab) => { ... });`
* `tab.on("active", (tab) => { ... });` * `tab.on("active", (tab) => { ... });`

View file

@ -403,11 +403,14 @@ const TabPrivate = {
this.webview.addEventListener("did-finish-load", tabWebviewDidFinishLoadHandler.bind(this), false); this.webview.addEventListener("did-finish-load", tabWebviewDidFinishLoadHandler.bind(this), false);
this.webview.addEventListener("dom-ready", function () { const tabWebviewDomReadyHandler = function (e) {
// Remove this once https://github.com/electron/electron/issues/14474 is fixed // Remove this once https://github.com/electron/electron/issues/14474 is fixed
webview.blur(); webview.blur();
webview.focus(); webview.focus();
}); this.emit("webview-dom-ready", this);
};
this.webview.addEventListener("dom-ready", tabWebviewDomReadyHandler.bind(this), false);
this.webview.classList.add(this.tabGroup.options.viewClass); this.webview.classList.add(this.tabGroup.options.viewClass);
if (this.webviewAttributes) { if (this.webviewAttributes) {