Selecting the right diversion for the condition

This commit is contained in:
Ruben van de Ven 2019-06-16 18:07:49 +02:00
parent ee1a2e39f2
commit be26add0c1

7
www/js/crel.min.js vendored
View file

@ -10,9 +10,12 @@ crel.attrMap['options'] = function(element, values, a, b) {
return;
}
let selectedValue = element.value ? element.value : element.attributes.value.value;
if(Array.isArray(values)) {
for (let option of values) {
if(element.value == option) {
if(selectedValue == option) {
element.appendChild(crel('option', {'selected': 'selected'}, option));
} else {
element.appendChild(crel('option', option));
@ -20,7 +23,7 @@ crel.attrMap['options'] = function(element, values, a, b) {
}
} else {
for (let option in values) {
if(element.value == option) {
if(selectedValue == option) {
element.appendChild(crel('option', {'selected': 'selected','value': option}, values[option]));
}else{
element.appendChild(crel('option', {'value': option}, values[option]));