Selecting the right diversion for the condition
This commit is contained in:
parent
ee1a2e39f2
commit
be26add0c1
1 changed files with 5 additions and 2 deletions
7
www/js/crel.min.js
vendored
7
www/js/crel.min.js
vendored
|
@ -9,10 +9,13 @@ crel.attrMap['options'] = function(element, values, a, b) {
|
||||||
if(element.tagName != "SELECT") {
|
if(element.tagName != "SELECT") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let selectedValue = element.value ? element.value : element.attributes.value.value;
|
||||||
|
|
||||||
if(Array.isArray(values)) {
|
if(Array.isArray(values)) {
|
||||||
for (let option of values) {
|
for (let option of values) {
|
||||||
if(element.value == option) {
|
if(selectedValue == option) {
|
||||||
element.appendChild(crel('option', {'selected': 'selected'}, option));
|
element.appendChild(crel('option', {'selected': 'selected'}, option));
|
||||||
} else {
|
} else {
|
||||||
element.appendChild(crel('option', option));
|
element.appendChild(crel('option', option));
|
||||||
|
@ -20,7 +23,7 @@ crel.attrMap['options'] = function(element, values, a, b) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (let option in values) {
|
for (let option in values) {
|
||||||
if(element.value == option) {
|
if(selectedValue == option) {
|
||||||
element.appendChild(crel('option', {'selected': 'selected','value': option}, values[option]));
|
element.appendChild(crel('option', {'selected': 'selected','value': option}, values[option]));
|
||||||
}else{
|
}else{
|
||||||
element.appendChild(crel('option', {'value': option}, values[option]));
|
element.appendChild(crel('option', {'value': option}, values[option]));
|
||||||
|
|
Loading…
Reference in a new issue