After experimenting with Aris a bit, I found that the array-mapping feature didn't seem to support accessing the current array index.
Here's a (modified) example from some code I have that shows what I mean.
let checked = true;
inputRowEl.innerHTML = ["div", {class: "radio-set"},
option.options, (opt, i) => {
let retVal = ["label", {class: "radio-label"},
["span", {class: "check-radio-text"}, opt.label],
["input", {
type: "radio",
id: "opt-" + option.id + "-" + opt.id,
name: option.id,
value: opt.id,
checked: [checked]
}],
["span", {class: "radio-ball"}]
];
checked = false;
return retVal;
}
];
I feel like this would be simplified (and more consistent with map()
) if the array index could be accessed as an argument, like so:
inputRowEl.innerHTML = ["div", {class: "radio-set"},
option.options, (opt, i) => {
return ["label", {class: "radio-label"},
["span", {class: "check-radio-text"}, opt.label],
["input", {
type: "radio",
id: "opt-" + option.id + "-" + opt.id,
name: option.id,
value: opt.id,
checked: [i == 0]
}],
["span", {class: "radio-ball"}]
];
}
];