Replace a bunch of Array.prototype.forEach() cases with for...of loops instead

Using `for...of` is a modern and generally much nicer pattern, since it gets rid of unnecessary callback-functions. (In a couple of spots, a "regular" `for` loop had to be used.)
This commit is contained in:
Jonas Jenwald 2021-04-24 12:36:01 +02:00
parent da0e7ea969
commit da22146b95
14 changed files with 67 additions and 71 deletions

View file

@ -343,9 +343,9 @@ class AnnotationElement {
assert(this.quadrilaterals, "Missing quadrilaterals during rendering");
}
this.quadrilaterals.forEach(quadrilateral => {
for (const quadrilateral of this.quadrilaterals) {
quadrilateral.className = className;
});
}
return this.quadrilaterals;
}
@ -1445,11 +1445,11 @@ class PopupElement {
}
// Attach the event listeners to the trigger element.
this.trigger.forEach(element => {
for (const element of this.trigger) {
element.addEventListener("click", this._toggle.bind(this));
element.addEventListener("mouseover", this._show.bind(this, false));
element.addEventListener("mouseout", this._hide.bind(this, false));
});
}
popup.addEventListener("click", this._hide.bind(this, true));
wrapper.appendChild(popup);
@ -2104,9 +2104,9 @@ class AnnotationLayer {
`[data-annotation-id="${data.id}"]`
);
if (elements) {
elements.forEach(element => {
for (const element of elements) {
element.style.transform = transform;
});
}
}
}
parameters.div.hidden = false;