Guard against only specifying select or highlight handler
This commit is contained in:
parent
0dcdd60010
commit
5e70adb511
1 changed files with 4 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue