mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
fix(checkbox): defaulting to invalid name and value attributes (#7130)
Fixes the checkbox defaulting to `name="null"` and `value="undefined"` for the underlying input, if the user hasn't passed them in.
This commit is contained in:
committed by
Andrew Seguin
parent
c5e162b1b0
commit
26788f19c7
@@ -6,9 +6,9 @@
|
||||
[id]="inputId"
|
||||
[required]="required"
|
||||
[checked]="checked"
|
||||
[value]="value"
|
||||
[attr.value]="value"
|
||||
[disabled]="disabled"
|
||||
[name]="name"
|
||||
[attr.name]="name"
|
||||
[tabIndex]="tabIndex"
|
||||
[indeterminate]="indeterminate"
|
||||
[attr.aria-label]="ariaLabel"
|
||||
|
||||
@@ -873,6 +873,17 @@ describe('MatCheckbox', () => {
|
||||
.not.toContain('mat-checkbox-inner-container-no-side-margin');
|
||||
}, 1);
|
||||
}));
|
||||
|
||||
it('should not add the "name" attribute if it is not passed in', () => {
|
||||
fixture.detectChanges();
|
||||
expect(checkboxInnerContainer.querySelector('input')!.hasAttribute('name')).toBe(false);
|
||||
});
|
||||
|
||||
it('should not add the "value" attribute if it is not passed in', () => {
|
||||
fixture.detectChanges();
|
||||
expect(checkboxInnerContainer.querySelector('input')!.hasAttribute('value')).toBe(false);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -169,7 +169,7 @@ export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAc
|
||||
@Output() indeterminateChange: EventEmitter<boolean> = new EventEmitter<boolean>();
|
||||
|
||||
/** The value attribute of the native input element */
|
||||
@Input() value: string ;
|
||||
@Input() value: string;
|
||||
|
||||
/** The native `<input type="checkbox"> element */
|
||||
@ViewChild('input') _inputElement: ElementRef;
|
||||
|
||||
Reference in New Issue
Block a user