Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/material/legacy-radio/radio.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ describe('MatRadio', () => {
}
});

it('should clear the name attribute from the radio group host node', () => {
expect(groupInstance.name).toBeTruthy();
expect(groupDebugElement.nativeElement.getAttribute('name')).toBeFalsy();
});

it('should coerce the disabled binding on the radio group', () => {
(groupInstance as any).disabled = '';
fixture.detectChanges();
Expand Down
1 change: 1 addition & 0 deletions src/material/legacy-radio/radio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export class MatLegacyRadioGroup extends _MatRadioGroupBase<MatLegacyRadioButton
'[attr.aria-label]': 'null',
'[attr.aria-labelledby]': 'null',
'[attr.aria-describedby]': 'null',
'[attr.name]': 'null',
// Note: under normal conditions focus shouldn't land on this element, however it may be
// programmatically set, for example inside of a focus trap, in this case we want to forward
// the focus to the native element.
Expand Down
9 changes: 9 additions & 0 deletions src/material/radio/radio.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ describe('MDC-based MatRadio', () => {
}
});

it('should clear the name attribute from the radio group host node', () => {
expect(groupInstance.name).toBeTruthy();
expect(groupDebugElement.nativeElement.getAttribute('name')).toBeFalsy();
});

it('should coerce the disabled binding on the radio group', () => {
(groupInstance as any).disabled = '';
fixture.detectChanges();
Expand Down Expand Up @@ -821,6 +826,10 @@ describe('MDC-based MatRadio', () => {
it('should default the radio color to `accent`', () => {
expect(seasonRadioInstances.every(radio => radio.color === 'accent')).toBe(true);
});

it('should clear the name attribute from the radio host node', () => {
expect(radioDebugElements.every(el => !el.nativeElement.getAttribute('name'))).toBe(true);
});
});

describe('with tabindex', () => {
Expand Down
1 change: 1 addition & 0 deletions src/material/radio/radio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ export class MatRadioGroup extends _MatRadioGroupBase<MatRadioButton> {
'[attr.aria-label]': 'null',
'[attr.aria-labelledby]': 'null',
'[attr.aria-describedby]': 'null',
'[attr.name]': 'null',
// Note: under normal conditions focus shouldn't land on this element, however it may be
// programmatically set, for example inside of a focus trap, in this case we want to forward
// the focus to the native element.
Expand Down