keyboard: setValue: prevent error if index doesn't match a key

This commit is contained in:
jean-emmanuel 2022-02-02 13:35:51 +01:00
parent 1c69c029dc
commit 29e18ef23c

View file

@ -156,8 +156,10 @@ class Keyboard extends Panel {
if (!Array.isArray(v) || v.length !== 2) return
if (v[1] !== this.getProp('on') && v[1] !== this.getProp('off')) return
var start = parseInt(this.getProp('start'))
this.children[v[0] - start].setValue(v[1] === this.getProp('on') ? 1 : 0, options)
var index = v[0] - parseInt(this.getProp('start'))
if (this.children[index]) {
this.children[index].setValue(v[1] === this.getProp('on') ? 1 : 0, options)
}
}