Return early when touchBar is null

This commit is contained in:
Kevin Sawicki 2017-02-27 11:23:33 -08:00
parent 69638a399c
commit eff49ad19c

View file

@ -205,13 +205,16 @@ Object.assign(BrowserWindow.prototype, {
// TouchBar API // TouchBar API
BrowserWindow.prototype.setTouchBar = function (touchBar) { BrowserWindow.prototype.setTouchBar = function (touchBar) {
if (touchBar === null || typeof touchBar === 'undefined') { if (touchBar == null) {
this._destroyTouchBar() this._destroyTouchBar()
} else if (Array.isArray(touchBar)) { return
this._setTouchBar((new TouchBar(touchBar)).toJSON())
} else {
this._setTouchBar(touchBar.toJSON())
} }
if (Array.isArray(touchBar)) {
touchBar = new TouchBar(touchBar)
}
this._setTouchBar(touchBar.toJSON())
touchBar._owner = this touchBar._owner = this
touchBar.items.forEach((item) => { touchBar.items.forEach((item) => {
item._owner = this item._owner = this