replace for..in for loops for for..of + destructuring

This commit is contained in:
Johannes Kimmel 2023-04-25 13:06:06 +02:00
parent 89a4687c81
commit 6368a9882a
1 changed files with 5 additions and 6 deletions

View File

@ -25,8 +25,8 @@ function makeText(text) {
function makeInput(id, attrs) { function makeInput(id, attrs) {
let ret = document.createElement('input'); let ret = document.createElement('input');
ret.setAttribute('id', id); ret.setAttribute('id', id);
for (const attr in attrs) { for (const [attr, value] of Object.entries(attrs)) {
ret.setAttribute(attr, attrs[attr]); ret.setAttribute(attr, value);
} }
return ret; return ret;
} }
@ -68,8 +68,7 @@ class L3Section {
} }
let optstrs = []; let optstrs = [];
for (const opt in compiledopts) { for (const [opt, values] of Object.entries(compiledopts)) {
const values = compiledopts[opt];
if (values.length == 1) { if (values.length == 1) {
optstrs.push(`option ${opt} '${values[0]}'`); optstrs.push(`option ${opt} '${values[0]}'`);
} else { } else {
@ -208,8 +207,8 @@ class L3Select {
this.input = document.createElement('select'); this.input = document.createElement('select');
this.input.setAttribute('id', this.id); this.input.setAttribute('id', this.id);
for (const attr in this.attrs) { for (const [attr, value] of Object.entries(this.attrs)) {
this.input.setAttribute(attr, this.attrs[attr]); this.input.setAttribute(attr, value);
} }
div.appendChild(this.input); div.appendChild(this.input);