8000 fix: make menu.popup options optional by doms · Pull Request #13977 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 4 commits into from
Aug 8, 2018
Merged

Conversation

doms
Copy link
Contributor
@doms doms commented Aug 8, 2018

Background

fixes #12915

The menu.popup options object has all optional fields. One would think with that being the case, the options 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.

Menu.prototype.popup = function (options = {}) {
	// ...
}
Checklist
  • PR description included and stakeholders cc'd
  • npm test passes
  • tests are changed or added
  • relevant documentation is changed or added
  • PR title follows semantic commit guidelines

@doms doms requested review from a team August 8, 2018 06:23
@welcome
Copy link
welcome bot commented Aug 8, 2018

💖 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:

  • fix: don't overwrite prevent_default if default wasn't prevented
  • feat: add app.isPackaged() method
  • docs: app.isDefaultProtocolClient is now available on Linux

Things that will help get your PR across the finish line:

  • Follow the JavaScript, C++, and Python coding style.
  • Run npm run lint locally to catch formatting errors earlier.
  • Document any user-facing changes you've made following the documentation styleguide.
  • Include tests when adding/changing behavior.
  • Include screenshots and animated GIFs whenever possible.

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.

@doms doms changed the title fix: make menu.popup options optional [WIP] fix: make menu.popup options optional Aug 8, 2018
Menu.prototype.popup = function (options) {
if (options == null || typeof options !== 'object') {
Menu.prototype.popup = function (options = {}) {
if (typeof options !== 'object') {
Copy link
Member

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'

@doms doms changed the title [WIP] fix: make menu.popup options optional fix: make menu.popup options optional Aug 8, 2018
Copy link
Member
@ckerr ckerr left a 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')
Copy link
Member

Choose a reason for hiding this comment

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

😃

@ckerr
Copy link
Member
ckerr commented Aug 8, 2018

Merging because the CI failures appear to be unrelated flakes. The menu.popup tests are passing:

ok 405 Menu module Menu.popup throws an error if options is not an object
ok 406 Menu module Menu.popup allows for options to be optional
ok 407 Menu module Menu.popup should emit menu-will-show event
ok 408 Menu module Menu.popup should emit menu-will-close event
ok 409 Menu module Menu.popup returns immediately
ok 410 Menu module Menu.popup works without a given BrowserWindow and options
ok 411 Menu module Menu.popup works with a given BrowserWindow, options and callback
ok 412 Menu module Menu.popup works with a given BrowserWindow, no options, and a callback

@ckerr ckerr merged commit a7052ef into master Aug 8, 2018
@welcome
Copy link
welcome bot commented Aug 8, 2018

Congrats on merging your first pull request! 🎉🎉🎉

@ckerr ckerr deleted the doms/optional-menu-object branch August 8, 2018 22:38
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.

menu.popup options object should be optional
3 participants
0