mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
fix(checkbox): support OnPush for disabled with forms module (#4087)
This commit is contained in:
committed by
Jeremy Elbourn
parent
02b2cc9210
commit
efb39da377
@@ -710,6 +710,7 @@ describe('MdCheckbox', () => {
|
||||
let checkboxDebugElement: DebugElement;
|
||||
let checkboxInstance: MdCheckbox;
|
||||
let testComponent: CheckboxWithFormControl;
|
||||
let inputElement: HTMLInputElement;
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(CheckboxWithFormControl);
|
||||
@@ -718,6 +719,7 @@ describe('MdCheckbox', () => {
|
||||
checkboxDebugElement = fixture.debugElement.query(By.directive(MdCheckbox));
|
||||
checkboxInstance = checkboxDebugElement.componentInstance;
|
||||
testComponent = fixture.debugElement.componentInstance;
|
||||
inputElement = <HTMLInputElement>checkboxDebugElement.nativeElement.querySelector('input');
|
||||
});
|
||||
|
||||
it('should toggle the disabled state', () => {
|
||||
@@ -727,11 +729,13 @@ describe('MdCheckbox', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(checkboxInstance.disabled).toBe(true);
|
||||
expect(inputElement.disabled).toBe(true);
|
||||
|
||||
testComponent.formControl.enable();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(checkboxInstance.disabled).toBe(false);
|
||||
expect(inputElement.disabled).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -304,6 +304,7 @@ export class MdCheckbox implements ControlValueAccessor, AfterViewInit, OnDestro
|
||||
*/
|
||||
setDisabledState(isDisabled: boolean) {
|
||||
this.disabled = isDisabled;
|
||||
this._changeDetectorRef.markForCheck();
|
||||
}
|
||||
|
||||
private _transitionCheckState(newState: TransitionCheckState) {
|
||||
|
||||
Reference in New Issue
Block a user