Skip to content

Commit 904c71e

Browse files
devversiontinayuangao
authored andcommitted
fix(slide-toggle): fix unavailable unmonitor call (#3862)
* fix(slide-toggle): fix unavailable unmonitor call * Remove variable
1 parent 724170d commit 904c71e

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

src/lib/checkbox/checkbox.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ describe('MdCheckbox', () => {
363363
expect(fixture.nativeElement.querySelectorAll('.mat-ripple-element').length)
364364
.toBe(0, 'Expected no ripples to be present.');
365365

366-
fakeFocusOriginMonitorSubject.next('program');
366+
dispatchFakeEvent(inputElement, 'focus');
367367
tick(RIPPLE_FADE_IN_DURATION);
368368

369369
expect(fixture.nativeElement.querySelectorAll('.mat-ripple-element').length)

src/lib/slide-toggle/slide-toggle.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
} from '../core';
2424
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';
2525
import {Observable} from 'rxjs/Observable';
26-
import {Subscription} from 'rxjs/Subscription';
2726

2827
export const MD_SLIDE_TOGGLE_VALUE_ACCESSOR: any = {
2928
provide: NG_VALUE_ACCESSOR,
@@ -77,9 +76,6 @@ export class MdSlideToggle implements OnDestroy, AfterContentInit, ControlValueA
7776
/** Reference to the focus state ripple. */
7877
private _focusRipple: RippleRef;
7978

80-
/** Subscription to focus-origin changes. */
81-
private _focusOriginSubscription: Subscription;
82-
8379
/** Name value will be applied to the input element if present */
8480
@Input() name: string = null;
8581

@@ -133,18 +129,13 @@ export class MdSlideToggle implements OnDestroy, AfterContentInit, ControlValueA
133129
ngAfterContentInit() {
134130
this._slideRenderer = new SlideToggleRenderer(this._elementRef);
135131

136-
this._focusOriginSubscription = this._focusOriginMonitor
132+
this._focusOriginMonitor
137133
.monitor(this._inputElement.nativeElement, this._renderer, false)
138134
.subscribe(focusOrigin => this._onInputFocusChange(focusOrigin));
139135
}
140136

141137
ngOnDestroy() {
142-
this._focusOriginMonitor.unmonitor(this._inputElement.nativeElement);
143-
144-
if (this._focusOriginSubscription) {
145-
this._focusOriginSubscription.unsubscribe();
146-
this._focusOriginSubscription = null;
147-
}
138+
this._focusOriginMonitor.stopMonitoring(this._inputElement.nativeElement);
148139
}
149140

150141
/**

0 commit comments

Comments
 (0)