Guard against only specifying select or highlight handler

This commit is contained in:
Kevin Sawicki 2017-03-13 11:22:08 -07:00
parent 0dcdd60010
commit 5e70adb511

View file

@ -235,11 +235,14 @@ TouchBar.TouchBarScrubber = class TouchBarScrubber extends TouchBarItem {
constructor (config) {
super()
if (config == null) config = {}
const {items, onSelect, onHighlight} = config
const {items} = config
let {onSelect, onHighlight} = config
this.type = 'scrubber'
this._addLiveProperty('items', items)
if (typeof onSelect === 'function' || typeof onHighlight === 'function') {
if (onSelect == null) onSelect = () => {}
if (onHighlight == null) onHighlight = () => {}
this.onInteraction = (details) => {
if (details.type === 'select') {
onSelect(details.selectedIndex)