mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
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:
parent
b723734b72
commit
cd20dd07ce
1 changed files with 4 additions and 4 deletions
|
|
@ -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);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue