Browse Source

fix: 'page-title-updated' event forwarding + documentation (#18320)

trop[bot] 6 years ago
parent
commit
e77b6878a9
3 changed files with 15 additions and 2 deletions
  1. 2 0
      docs/api/browser-window.md
  2. 11 0
      docs/api/web-contents.md
  3. 2 2
      lib/browser/api/browser-window.js

+ 2 - 0
docs/api/browser-window.md

@@ -406,9 +406,11 @@ Returns:
 
 * `event` Event
 * `title` String
+* `explicitSet` Boolean
 
 Emitted when the document changed its title, calling `event.preventDefault()`
 will prevent the native window's title from changing.
+`explicitSet` is false when title is synthesized from file url.
 
 #### Event: 'close'
 

+ 11 - 0
docs/api/web-contents.md

@@ -101,6 +101,17 @@ Returns:
 
 Emitted when the document in the given frame is loaded.
 
+#### Event: 'page-title-updated'
+
+Returns:
+
+* `event` Event
+* `title` String
+* `explicitSet` Boolean
+
+Fired when page title is set during navigation. `explicitSet` is false when
+title is synthesized from file url.
+
 #### Event: 'page-favicon-updated'
 
 Returns:

+ 2 - 2
lib/browser/api/browser-window.js

@@ -39,9 +39,9 @@ BrowserWindow.prototype._init = function () {
   })
 
   // Change window title to page title.
-  this.webContents.on('page-title-updated', (event, title) => {
+  this.webContents.on('page-title-updated', (event, title, ...args) => {
     // Route the event to BrowserWindow.
-    this.emit('page-title-updated', event, title)
+    this.emit('page-title-updated', event, title, ...args)
     if (!this.isDestroyed() && !event.defaultPrevented) this.setTitle(title)
   })