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:
Kristiyan Kostadinov
2017-09-29 22:10:43 +02:00
committed by Andrew Seguin
parent c5c96d9f6d
commit c5e162b1b0
2 changed files with 8 additions and 1 deletions
+1 -1
View File
@@ -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"
+7
View File
@@ -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 {