From 4cbbdbc0332159c0d4304ce12dbc57f381a1c28e Mon Sep 17 00:00:00 2001 From: Thomas Brouard Date: Fri, 28 Feb 2020 10:33:20 +0100 Subject: [PATCH] Add "webview-dom-ready" event --- README.md | 1 + index.js | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 561026e..2bb8052 100644 --- a/README.md +++ b/README.md @@ -216,6 +216,7 @@ The following events are available: * `tabGroup.on("tab-removed", (tab, tabGroup) => { ... });` * `tabGroup.on("tab-active", (tab, tabGroup) => { ... });` * `tab.on("webview-ready", (tab) => { ... });` +* `tab.on("webview-dom-ready", (tab) => { ... });` * `tab.on("title-changed", (title, tab) => { ... });` * `tab.on("icon-changed", (icon, tab) => { ... });` * `tab.on("active", (tab) => { ... });` diff --git a/index.js b/index.js index 13c2df8..0f615b0 100644 --- a/index.js +++ b/index.js @@ -403,11 +403,14 @@ const TabPrivate = { 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 - webview.blur(); - webview.focus(); - }); + webview.blur(); + 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); if (this.webviewAttributes) {