mirror of
https://github.com/umap-project/umap.git
synced 2025-04-29 11:52:38 +02:00
Merge pull request #2098 from umap-project/fix-ternary-value-comparison
fix: make sure to compare comparable values in ternary operators
This commit is contained in:
commit
b6a8742abd
1 changed files with 9 additions and 5 deletions
|
@ -902,8 +902,8 @@ L.FormBuilder.MultiChoice = L.FormBuilder.Element.extend({
|
||||||
if (!this.container.querySelector(`input[type="radio"][value="${value}"]`)) {
|
if (!this.container.querySelector(`input[type="radio"][value="${value}"]`)) {
|
||||||
value = this.options.default !== undefined ? this.options.default : this.default
|
value = this.options.default !== undefined ? this.options.default : this.default
|
||||||
}
|
}
|
||||||
const choices = this.getChoices().map(([value, label]) => value)
|
const choices = this.getChoices().map(([value, label]) => `${value}`)
|
||||||
if (choices.includes(value)) {
|
if (choices.includes(`${value}`)) {
|
||||||
this.container.querySelector(`input[type="radio"][value="${value}"]`).checked =
|
this.container.querySelector(`input[type="radio"][value="${value}"]`).checked =
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -925,8 +925,8 @@ L.FormBuilder.MultiChoice = L.FormBuilder.Element.extend({
|
||||||
`${this.className} by${choices.length}`,
|
`${this.className} by${choices.length}`,
|
||||||
this.parentNode
|
this.parentNode
|
||||||
)
|
)
|
||||||
for (let i = 0; i < choices.length; i++) {
|
for (const [i, [value, label]] of choices.entries()) {
|
||||||
this.addChoice(choices[i][0], choices[i][1], i)
|
this.addChoice(value, label, i)
|
||||||
}
|
}
|
||||||
this.fetch()
|
this.fetch()
|
||||||
},
|
},
|
||||||
|
@ -958,8 +958,12 @@ L.FormBuilder.TernaryChoices = L.FormBuilder.MultiChoice.extend({
|
||||||
case false:
|
case false:
|
||||||
value = false
|
value = false
|
||||||
break
|
break
|
||||||
default:
|
case 'null':
|
||||||
|
case null:
|
||||||
value = null
|
value = null
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
value = undefined
|
||||||
}
|
}
|
||||||
return value
|
return value
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue