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