Skip to content

Commit

Permalink
fix: BrowserWindow.fromWebContents() can return null
Browse files Browse the repository at this point in the history
  • Loading branch information
miniak committed Aug 27, 2019
1 parent bdb20d5 commit 7e52db4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/api/browser-window.md
Expand Up @@ -655,7 +655,8 @@ Returns `BrowserWindow | null` - The window that is focused in this application,

* `webContents` [WebContents](web-contents.md)

Returns `BrowserWindow` - The window that owns the given `webContents`.
Returns `BrowserWindow | null` - The window that owns the given `webContents`
or `null` if the contents are not owned by a window.

#### `BrowserWindow.fromBrowserView(browserView)`

Expand Down
2 changes: 2 additions & 0 deletions lib/browser/api/browser-window.js
Expand Up @@ -118,6 +118,8 @@ BrowserWindow.fromWebContents = (webContents) => {
for (const window of BrowserWindow.getAllWindows()) {
if (window.webContents.equal(webContents)) return window
}

return null
}

BrowserWindow.fromBrowserView = (browserView) => {
Expand Down

0 comments on commit 7e52db4

Please sign in to comment.