Make config optional

This commit is contained in:
Kevin Sawicki 2017-03-02 14:29:59 -08:00
parent ce12dcd3b4
commit eb03ab561d

View file

@ -90,7 +90,7 @@ class TouchBar extends EventEmitter {
}
class TouchBarItem extends EventEmitter {
constructor (config) {
constructor () {
super()
this.id = `${nextItemID++}`
}
@ -113,7 +113,8 @@ class TouchBarItem extends EventEmitter {
TouchBar.Button = class TouchBarButton extends TouchBarItem {
constructor (config) {
super(config)
super()
if (config == null) config = {}
this.type = 'button'
const {click, icon, label, backgroundColor} = config
this._addLiveProperty('label', label)
@ -127,7 +128,8 @@ TouchBar.Button = class TouchBarButton extends TouchBarItem {
TouchBar.ColorPicker = class TouchBarColorPicker extends TouchBarItem {
constructor (config) {
super(config)
super()
if (config == null) config = {}
this.type = 'colorpicker'
const {availableColors, change, selectedColor} = config
this._addLiveProperty('availableColors', availableColors)
@ -144,7 +146,8 @@ TouchBar.ColorPicker = class TouchBarColorPicker extends TouchBarItem {
TouchBar.Group = class TouchBarGroup extends TouchBarItem {
constructor (config) {
super(config)
super()
if (config == null) config = {}
this.type = 'group'
this.child = config.items
if (!(this.child instanceof TouchBar)) {
@ -155,7 +158,8 @@ TouchBar.Group = class TouchBarGroup extends TouchBarItem {
TouchBar.Label = class TouchBarLabel extends TouchBarItem {
constructor (config) {
super(config)
super()
if (config == null) config = {}
this.type = 'label'
this._addLiveProperty('label', config.label)
}
@ -163,7 +167,8 @@ TouchBar.Label = class TouchBarLabel extends TouchBarItem {
TouchBar.Spacer = class TouchBarSpacer extends TouchBarItem {
constructor (config) {
super(config)
super()
if (config == null) config = {}
this.type = 'spacer'
this._addLiveProperty('size', config.size)
}
@ -171,7 +176,8 @@ TouchBar.Spacer = class TouchBarSpacer extends TouchBarItem {
TouchBar.Popover = class TouchBarPopover extends TouchBarItem {
constructor (config) {
super(config)
super()
if (config == null) config = {}
this.type = 'popover'
this._addLiveProperty('label', config.label)
this._addLiveProperty('icon', config.icon)
@ -185,7 +191,8 @@ TouchBar.Popover = class TouchBarPopover extends TouchBarItem {
TouchBar.Slider = class TouchBarSlider extends TouchBarItem {
constructor (config) {
super(config)
super()
if (config == null) config = {}
this.type = 'slider'
const {change, label, minValue, maxValue, value} = config
this._addLiveProperty('label', label)