mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08: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:
committed by
Alex Rickabaugh
parent
b723734b72
commit
cd20dd07ce
@@ -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);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user