Skip to content

Commit

Permalink
fix: 'page-title-updated' event forwarding + documentation (#18320)
Browse files Browse the repository at this point in the history
  • Loading branch information
trop[bot] authored and zcbenz committed May 21, 2019
1 parent b763d81 commit e77b687
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/api/browser-window.md
Expand Up @@ -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'

Expand Down
11 changes: 11 additions & 0 deletions docs/api/web-contents.md
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions lib/browser/api/browser-window.js
Expand Up @@ -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)
})

Expand Down

0 comments on commit e77b687

Please sign in to comment.