Replace a couple of Array.prototype.forEach
-invocations with for..of
instead
Given that `NodeList`s can be iterated using `for..of` we can use that instead, since it's a little bit nicer and easier to read than the `Array.prototype.forEach` format.
This commit is contained in:
parent
09361a4bb4
commit
67a642c826
@ -1404,12 +1404,11 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
|
|||||||
selectElement.addEventListener("updatefromsandbox", jsEvent => {
|
selectElement.addEventListener("updatefromsandbox", jsEvent => {
|
||||||
const actions = {
|
const actions = {
|
||||||
value(event) {
|
value(event) {
|
||||||
const options = selectElement.options;
|
|
||||||
const value = event.detail.value;
|
const value = event.detail.value;
|
||||||
const values = new Set(Array.isArray(value) ? value : [value]);
|
const values = new Set(Array.isArray(value) ? value : [value]);
|
||||||
Array.prototype.forEach.call(options, option => {
|
for (const option of selectElement.options) {
|
||||||
option.selected = values.has(option.value);
|
option.selected = values.has(option.value);
|
||||||
});
|
}
|
||||||
storage.setValue(id, {
|
storage.setValue(id, {
|
||||||
value: getValue(event, /* isExport */ true),
|
value: getValue(event, /* isExport */ true),
|
||||||
});
|
});
|
||||||
@ -1478,10 +1477,9 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
|
|||||||
},
|
},
|
||||||
indices(event) {
|
indices(event) {
|
||||||
const indices = new Set(event.detail.indices);
|
const indices = new Set(event.detail.indices);
|
||||||
const options = event.target.options;
|
for (const option of event.target.options) {
|
||||||
Array.prototype.forEach.call(options, (option, i) => {
|
option.selected = indices.has(option.index);
|
||||||
option.selected = indices.has(i);
|
}
|
||||||
});
|
|
||||||
storage.setValue(id, {
|
storage.setValue(id, {
|
||||||
value: getValue(event, /* isExport */ true),
|
value: getValue(event, /* isExport */ true),
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user