Skip to content

Commit

Permalink
fix(button-toggle): inaccurate name passed down to input if no name i…
Browse files Browse the repository at this point in the history
…s assigned

Fixes the button toggle setting the underlying input's name to `"undefined"` if the consumer hasn't passed in a name.
  • Loading branch information
crisbeto committed Dec 27, 2017
1 parent c3d7cd9 commit 04b4c7d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/button-toggle/button-toggle.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[id]="inputId"
[checked]="checked"
[disabled]="disabled || null"
[name]="name"
[attr.name]="name"
[attr.aria-label]="ariaLabel"
[attr.aria-labelledby]="ariaLabelledby"
(change)="_onInputChange($event)"
Expand Down
4 changes: 4 additions & 0 deletions src/lib/button-toggle/button-toggle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,10 @@ describe('MatButtonToggle without forms', () => {
expect(document.activeElement).toBe(nativeRadioInput);
});

it('should not assign a name to the underlying input if one is not passed in', () => {
expect(buttonToggleNativeElement.querySelector('input')!.getAttribute('name')).toBeFalsy();
});

});

describe('with provided aria-label ', () => {
Expand Down

0 comments on commit 04b4c7d

Please sign in to comment.