diff --git a/src/lib/checkbox/checkbox.spec.ts b/src/lib/checkbox/checkbox.spec.ts index 2d87cc8cb981..4f8a6e657906 100644 --- a/src/lib/checkbox/checkbox.spec.ts +++ b/src/lib/checkbox/checkbox.spec.ts @@ -993,11 +993,17 @@ describe('MatCheckbox', () => { }); it('should forward name value to input element', () => { - let checkboxElement = fixture.debugElement.query(By.directive(MatCheckbox)); - let inputElement = checkboxElement.nativeElement.querySelector('input'); + const checkboxElement = fixture.debugElement.query(By.directive(MatCheckbox)); + const inputElement = checkboxElement.nativeElement.querySelector('input'); expect(inputElement.getAttribute('name')).toBe('test-name'); }); + + it('should clear the name attribute from the host node', () => { + const checkboxElement = fixture.debugElement.query(By.directive(MatCheckbox)); + + expect(checkboxElement.nativeElement.getAttribute('name')).toBeFalsy(); + }); }); describe('with form control', () => { diff --git a/src/lib/checkbox/checkbox.ts b/src/lib/checkbox/checkbox.ts index 31d1a0888392..e0dd40a3e6a7 100644 --- a/src/lib/checkbox/checkbox.ts +++ b/src/lib/checkbox/checkbox.ts @@ -115,6 +115,7 @@ export const _MatCheckboxMixinBase: 'class': 'mat-checkbox', '[id]': 'id', '[attr.tabindex]': 'null', + '[attr.name]': 'null', '[class.mat-checkbox-indeterminate]': 'indeterminate', '[class.mat-checkbox-checked]': 'checked', '[class.mat-checkbox-disabled]': 'disabled',