From c95117fb227f438b8dc622f124fb9096f6a915ed Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 1 Dec 2015 18:34:58 +0800 Subject: [PATCH] Delay the page-title-set event to next tick --- atom/browser/api/atom_api_web_contents.cc | 4 ++-- atom/browser/api/lib/web-contents.coffee | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 0c8a5ff3..b12b3fea 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -520,9 +520,9 @@ void WebContents::DidNavigateMainFrame( void WebContents::TitleWasSet(content::NavigationEntry* entry, bool explicit_set) { if (entry) - Emit("page-title-set", entry->GetTitle(), explicit_set); + Emit("-page-title-set", entry->GetTitle(), explicit_set); else - Emit("page-title-set", "", explicit_set); + Emit("-page-title-set", "", explicit_set); } void WebContents::DidUpdateFaviconURL( diff --git a/atom/browser/api/lib/web-contents.coffee b/atom/browser/api/lib/web-contents.coffee index 45545fe2..dbc9a15f 100644 --- a/atom/browser/api/lib/web-contents.coffee +++ b/atom/browser/api/lib/web-contents.coffee @@ -76,6 +76,10 @@ wrapWebContents = (webContents) -> # until next tick. setImmediate => @emit 'did-fail-load', args... + # Delays the page-title-set event to next tick. + webContents.on '-page-title-set', (args...) -> + setImmediate => @emit 'page-title-set', args... + # Deprecated. deprecate.rename webContents, 'loadUrl', 'loadURL' deprecate.rename webContents, 'getUrl', 'getURL' -- 2.43.0