diff --git a/lib/browser/api/browser-window.js b/lib/browser/api/browser-window.js index 31eac937a6e3..ecfd9195f430 100644 --- a/lib/browser/api/browser-window.js +++ b/lib/browser/api/browser-window.js @@ -205,13 +205,16 @@ Object.assign(BrowserWindow.prototype, { // TouchBar API BrowserWindow.prototype.setTouchBar = function (touchBar) { - if (touchBar === null || typeof touchBar === 'undefined') { + if (touchBar == null) { this._destroyTouchBar() - } else if (Array.isArray(touchBar)) { - this._setTouchBar((new TouchBar(touchBar)).toJSON()) - } else { - this._setTouchBar(touchBar.toJSON()) + return } + + if (Array.isArray(touchBar)) { + touchBar = new TouchBar(touchBar) + } + + this._setTouchBar(touchBar.toJSON()) touchBar._owner = this touchBar.items.forEach((item) => { item._owner = this