Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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