toggle: parse incomming value like push does

This commit is contained in:
jean-emmanuel 2018-05-10 23:01:34 +02:00
parent e4cc5b8625
commit 20ef7a2afe

View file

@ -82,13 +82,14 @@ class Toggle extends Widget {
setValue(v,options={}) {
if (v===this.getProp('on') || (this.getProp('on') != null && v.value === this.getProp('on').value && v.value !== undefined)) {
if (typeof v == 'object' && v !== null) v = v.value
if (v===this.getProp('on') || (this.getProp('on') != null && v === this.getProp('on').value && v !== undefined)) {
this.widget.classList.add('on')
this.container.classList.add('on')
this.state = 1
this.value = this.getProp('on')
if (options.send) this.sendValue()
} else if (v===this.getProp('off') || (this.getProp('off') != null && v.value === this.getProp('off').value && v.value !== undefined)) {
} else if (v===this.getProp('off') || (this.getProp('off') != null && v === this.getProp('off').value && v !== undefined)) {
this.widget.classList.remove('on')
this.container.classList.remove('on')
this.state = 0