widget: when possible, init value as soon as possible to avoid undefined when an array is expected.

This commit is contained in:
jean-emmanuel 2023-09-13 08:10:28 +02:00
parent 98a27de0df
commit cac9fb7abc
8 changed files with 6 additions and 11 deletions

View file

@ -201,6 +201,7 @@ class Widget extends EventEmitter {
this.isValueChanging = false
this.valueChangingTimeout = null
this.valueChangingQueue = {}
this.value = options.value
this.parsers = {}
this.parsersLocalScope = options.locals || {}

View file

@ -87,8 +87,6 @@ module.exports = class MultiXy extends Pad {
}
this.value = []
this.padsCoords = []
this.touchMap = {}

View file

@ -5,7 +5,7 @@ class Pad extends Canvas {
constructor(options) {
super({...options, html: html`
super({...options, value: [], html: html`
<inner>
<canvas></canvas>
</inner>

View file

@ -40,7 +40,7 @@ module.exports = class Rgb extends Widget {
constructor(options) {
super({...options, html: html`<inner></inner>`})
super({...options, value: [], html: html`<inner></inner>`})
this.container.classList.toggle('contains-alpha', this.getProp('alpha'))
@ -125,8 +125,6 @@ module.exports = class Rgb extends Widget {
}
this.value = []
this.hsb = {h:0,s:0,b:0}
this.setValue(initValue)

View file

@ -84,8 +84,6 @@ module.exports = class Xy extends Pad {
e.stopPropagation = true
})
this.value = []
touchstate(this, {element: this.canvas})
this.active = false

View file

@ -45,7 +45,7 @@ class Range extends Fader {
options.multitouch = true
super({...options, html: html`
super({...options, value: [], html: html`
<canvas></canvas>
`})

View file

@ -14,7 +14,6 @@ class Slider extends Canvas {
this.container.classList.add('design-' + this.getProp('design'))
this.value = undefined
this.percent = 0
this.gaugePadding = 0