Merge pull request #4969 from atom/null-dialog-callback

Add dialog callback fallback
This commit is contained in:
Kevin Sawicki 2016-04-01 16:11:09 -07:00
commit ef08138a8d

View file

@ -20,18 +20,25 @@ var messageBoxOptions = {
noLink: 1 << 0
}
var parseArgs = function (window, options, callback) {
var parseArgs = function (window, options, callback, ...args) {
if (!(window === null || (window != null ? window.constructor : void 0) === BrowserWindow)) {
// Shift.
callback = options
options = window
window = null
}
if ((callback == null) && typeof options === 'function') {
// Shift.
callback = options
options = null
}
// Fallback to using very last argument as the callback function
if ((callback == null) && typeof args[args.length - 1] === 'function') {
callback = args[args.length - 1]
}
return [window, options, callback]
}