Skip to content

fix(checkbox): defaulting to invalid name and value attributes #7130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 29, 2017
Merged
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
4 changes: 2 additions & 2 deletions src/lib/checkbox/checkbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 11 additions & 0 deletions src/lib/checkbox/checkbox.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,17 @@ describe('MdCheckbox', () => {
.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);
});

});
});

Expand Down
2 changes: 1 addition & 1 deletion src/lib/checkbox/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export class MdCheckbox extends _MdCheckboxMixinBase implements ControlValueAcce
@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;
Expand Down