8000 Allow buttons to be optional in 'showMessageBox' by danhp · Pull Request #8187 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Allow buttons to be optional in 'showMessageBox' #8187

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 1 commit into from
Dec 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
8000
Diff view
8 changes: 4 additions & 4 deletions lib/browser/api/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ module.exports = {

if (properties == null) {
properties = ['openFile']
}

if (!Array.isArray(properties)) {
} else if (!Array.isArray(properties)) {
throw new TypeError('Properties must be an array')
}

Expand Down Expand Up @@ -167,7 +165,9 @@ module.exports = {
throw new TypeError('Invalid message box type')
}

if (!Array.isArray(buttons)) {
if (buttons == null) {
buttons = []
} else if (!Array.isArray(buttons)) {
throw new TypeError('Buttons must be an array')
}

Expand Down
6 changes: 3 additions & 3 deletions spec/api-dialog-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ describe('dialog module', () => {
}, /Buttons must be an array/)

assert.throws(() => {
dialog.showMessageBox({title: 300, buttons: ['OK']})
dialog.showMessageBox({title: 300})
}, /Title must be a string/)

assert.throws(() => {
dialog.showMessageBox({message: [], buttons: ['OK']})
dialog.showMessageBox({message: []})
}, /Message must be a string/)

assert.throws(() => {
dialog.showMessageBox({detail: 3.14, buttons: ['OK']})
dialog.showMessageBox({detail: 3.14})
}, /Detail must be a string/)
})
})
Expand Down
0