diff --git a/src/lib/checkbox/checkbox.html b/src/lib/checkbox/checkbox.html index 1361d936248..3174c680446 100644 --- a/src/lib/checkbox/checkbox.html +++ b/src/lib/checkbox/checkbox.html @@ -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" diff --git a/src/lib/checkbox/checkbox.spec.ts b/src/lib/checkbox/checkbox.spec.ts index 73b6f50177f..d71a3daeb22 100644 --- a/src/lib/checkbox/checkbox.spec.ts +++ b/src/lib/checkbox/checkbox.spec.ts @@ -873,6 +873,17 @@ describe('MatCheckbox', () => { .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); + }); + }); }); diff --git a/src/lib/checkbox/checkbox.ts b/src/lib/checkbox/checkbox.ts index 97ffec3de20..c17cc728bc0 100644 --- a/src/lib/checkbox/checkbox.ts +++ b/src/lib/checkbox/checkbox.ts @@ -169,7 +169,7 @@ export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAc @Output() indeterminateChange: EventEmitter = new EventEmitter(); /** The value attribute of the native input element */ - @Input() value: string ; + @Input() value: string; /** The native ` element */ @ViewChild('input') _inputElement: ElementRef;