-
Notifications
You must be signed in to change notification settings - Fork 16.2k
fix: make menu.popup options optional #13977
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
Conversation
💖 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. |
lib/browser/api/menu.js
Outdated
Menu.prototype.popup = function (options) { | ||
if (options == null || typeof options !== 'object') { | ||
Menu.prototype.popup = function (options = {}) { | ||
if (typeof options !== 'object') { |
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.
We still need the null
check here, null
won't be defaulted and typeof null === 'object'
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.
Looks good to me. Thanks for the patch, Dominic!
@@ -633,10 +633,16 @@ describe('Menu module', () => { | |||
|
|||
it('throws an error if options is not an object', () => { | |||
expect(() => { | |||
menu.popup() | |||
menu.popup('this is a string, not an object') |
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.
😃
Merging because the CI failures appear to be unrelated flakes. The
|
Congrats on merging your first pull request! 🎉🎉🎉 |
Background
fixes #12915
The menu.popup
options
object has all optional fields. One would think with that being the case, theoptions
object as a whole could be optional.Implementation
This PR adds a default param to
Menu.prototype.popup
that will allow the function to work, even when an object is passed in.Checklist
npm test
passes