Browse Source

Merge pull request #8187 from electron/optional-buttons

Allow buttons to be optional in 'showMessageBox'
Kevin Sawicki 8 years ago
parent
commit
cb7715a572
2 changed files with 7 additions and 7 deletions
  1. 4 4
      lib/browser/api/dialog.js
  2. 3 3
      spec/api-dialog-spec.js

+ 4 - 4
lib/browser/api/dialog.js

@@ -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')
     }
 
@@ -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')
     }
 

+ 3 - 3
spec/api-dialog-spec.js

@@ -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/)
     })
   })