mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
fix(radio): defaulting to invalid name attribute (#7131)
Fixes the radio button defaulting to `name="undefined"` for the underlying input, if the consumer hasn't passed in a name. Relates to #7130.
This commit is contained in:
committed by
Andrew Seguin
parent
c5c96d9f6d
commit
c5e162b1b0
@@ -15,7 +15,7 @@
|
||||
[id]="inputId"
|
||||
[checked]="checked"
|
||||
[disabled]="disabled"
|
||||
[name]="name"
|
||||
[attr.name]="name"
|
||||
[required]="required"
|
||||
[attr.aria-label]="ariaLabel"
|
||||
[attr.aria-labelledby]="ariaLabelledby"
|
||||
|
||||
@@ -638,6 +638,12 @@ describe('MatRadio', () => {
|
||||
expect(document.activeElement).toBe(fruitRadioNativeInputs[i]);
|
||||
}
|
||||
});
|
||||
|
||||
it('should not add the "name" attribute if it is not passed in', () => {
|
||||
const radio = fixture.debugElement.nativeElement.querySelector('#nameless input');
|
||||
expect(radio.hasAttribute('name')).toBe(false);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('with tabindex', () => {
|
||||
@@ -711,6 +717,7 @@ class RadiosInsideRadioGroup {
|
||||
[aria-labelledby]="ariaLabelledby">
|
||||
</mat-radio-button>
|
||||
<mat-radio-button name="fruit" value="raspberry">Raspberry</mat-radio-button>
|
||||
<mat-radio-button id="nameless" value="no-name">No name</mat-radio-button>
|
||||
`
|
||||
})
|
||||
class StandaloneRadioButtons {
|
||||
|
||||
Reference in New Issue
Block a user