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
docs: browserView.webContents
can be null
#40569
base: main
Are you sure you want to change the base?
Conversation
Fixes: electron#40567 `null` was introduced as a possibility for destroyed webContents in this PR: electron#25411
💖 Thanks for opening this pull request! 💖 We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix. Examples of commit messages with semantic prefixes:
Things that will help get your PR across the finish line:
We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can. |
null
as type for browserView.webContents
null
as type for browserView.webContents
null
as type for browserView.webContents
null
as type for browserView.webContents
null
as type for browserView.webContents
browserView.webContents
can be null
I need some help, tried to get and failed to get the project running & reproduce the CI issue locally. I copied another part of the docs hoping this issue would disappear but it looks like it keeps happening regardless. If anyone can help out this would be great! I'm getting the following issue:
|
docs/api/browser-view.md
Outdated
@@ -41,7 +41,10 @@ Objects created with `new BrowserView` have the following properties: | |||
|
|||
#### `view.webContents` _Experimental_ | |||
|
|||
A [`WebContents`](web-contents.md) object owned by this view. | |||
* `webContents` [WebContents](web-contents.md) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Juice10 bullet points in properties aren't stylistically valid in our parsing logic - this should be removed. Bullet pointed items are parsed to refer to parameters passed to a function, of which a property would have none. Simply adding what you already did below:
A
WebContents | null
property that returns theWebContents
owned by this view
ornull
if the contents are destroyed.
Fixes the issue. You can verify this by looking at the Archaeologist
check in CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@codebytere, thanks for the suggestion, I really appreciate it! Unfortunately I'm still getting the same error. I've even tried a couple variations on what you suggested, but the error is still the same.
Any chance you could take another look? I'd be happy to tweak it again, but I'm a bit lost in what to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you try:
A
WebContents | null
property that returns theWebContents
owned by this view
ornull
if the contents are destroyed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replacing Returns WebContents | null
with A WebContents | null
fixed the issue!
I'm getting another issue now but it's no longer a docs parsing issue, but a typing issue so this is progress! Thanks for the help @codebytere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank for the fix (and for being patient through some snags!)
oh fun, one more issue - not with the docs though! Looks like your change surfaced an actual types issue in |
Thanks for catching that @codebytere! I've added a fix for the issue you mentioned 16e636d. Hopefully this fixes it. |
@@ -91,6 +91,8 @@ BrowserWindow.fromWebContents = (webContents: WebContents) => { | |||
}; | |||
|
|||
BrowserWindow.fromBrowserView = (browserView: BrowserView) => { | |||
const { webContents } = browserView; | |||
if (!webContents) return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you'll need to update the docs for BrowserWindow.fromBrowserView
to state that it can return null
, too.
Looks like there are a bunch of type issues now in electron/spec/api-browser-view-spec.ts, which makes sense. |
Add |
Description of Change
null
was introduced as a possibility for destroyedwebContents
by @mlaurencin in: #25411This change updates the documentation (and hopefully the typescript types) to reflect that.
Fixes: #40567
Checklist
Release Notes
Notes:
browserView.webContents
types now correctly reflects that destroyedwebContents
can be set tonull