fix(forms): correct usage of selectedOptions
(#37620)
Previously, `registerOnChange` used `hasOwnProperty` to identify if the property is supported. However, this does not work as the `selectedOptions` property is an inherited property. This commit fixes this by verifying the property on the prototype instead. Closes #37433 PR Close #37620
This commit is contained in:

committed by
Andrew Kushnir

parent
69948ce919
commit
dfb58c44a2
@ -156,7 +156,7 @@ export class SelectMultipleControlValueAccessor implements ControlValueAccessor
|
||||
registerOnChange(fn: (value: any) => any): void {
|
||||
this.onChange = (_: any) => {
|
||||
const selected: Array<any> = [];
|
||||
if (_.hasOwnProperty('selectedOptions')) {
|
||||
if (_.selectedOptions !== undefined) {
|
||||
const options: HTMLCollection = _.selectedOptions;
|
||||
for (let i = 0; i < options.length; i++) {
|
||||
const opt: any = options.item(i);
|
||||
|
Reference in New Issue
Block a user