refactor(forms): improve clarity in SelectMultipleControlValueAccessor.writeValue

Rename the _optionMap forEach parameter from `o` to `id` and tighten its
type from `any` to `string`, removing the now-redundant `.toString()` call.
This commit is contained in:
Sam Severance 2026-05-01 10:04:58 -04:00 committed by Alex Rickabaugh
parent b723734b72
commit cd20dd07ce

View file

@ -126,15 +126,15 @@ export class SelectMultipleControlValueAccessor
*/
writeValue(value: any): void {
this.value = value;
let optionSelectedStateSetter: (opt: ɵNgSelectMultipleOption, o: any) => void;
let optionSelectedStateSetter: (opt: ɵNgSelectMultipleOption, id: string) => void;
if (Array.isArray(value)) {
// convert values to ids
const ids = value.map((v) => this._getOptionId(v));
optionSelectedStateSetter = (opt, o) => {
opt._setSelected(ids.indexOf(o.toString()) > -1);
optionSelectedStateSetter = (opt, id) => {
opt._setSelected(ids.indexOf(id) > -1);
};
} else {
optionSelectedStateSetter = (opt, o) => {
optionSelectedStateSetter = (opt) => {
opt._setSelected(false);
};
}