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: allow passing WebContents to the window option #185

Merged
merged 2 commits into from
Aug 29, 2024

Conversation

quanglam2807
Copy link
Contributor

@quanglam2807 quanglam2807 commented Aug 29, 2024

@quanglam2807 quanglam2807 changed the title fix: passing WebContents to the window option fix: allow passing WebContents to the window option Aug 29, 2024
@sindresorhus
Copy link
Owner

Ensure you have manually tested this with the supported typed: BrowserWindow | BrowserView | WebViewTag | WebContents

if (win.once !== undefined) { // Support for BrowserView
win.webContents.once('destroyed', disposable);
}
webContents(win).once('destroyed', disposable);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

win is not always BrowserWindow, so we must use utils to get WebContents:

const webContents = win => win.webContents ?? (win.id && win);

@quanglam2807
Copy link
Contributor Author

@sindresorhus Thanks for reminding! I've tested it.

@sindresorhus sindresorhus merged commit fe0e088 into sindresorhus:main Aug 29, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v4.0.2+ breaks if window option is WebContents
2 participants