Skip to content

Commit

Permalink
fix(slide-toggle): fix unavailable unmonitor call (#3862)
Browse files Browse the repository at this point in the history
* fix(slide-toggle): fix unavailable unmonitor call

* Remove variable
  • Loading branch information
devversion authored and tinayuangao committed Mar 31, 2017
1 parent 724170d commit 904c71e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/lib/checkbox/checkbox.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ describe('MdCheckbox', () => {
expect(fixture.nativeElement.querySelectorAll('.mat-ripple-element').length)
.toBe(0, 'Expected no ripples to be present.');

fakeFocusOriginMonitorSubject.next('program');
dispatchFakeEvent(inputElement, 'focus');
tick(RIPPLE_FADE_IN_DURATION);

expect(fixture.nativeElement.querySelectorAll('.mat-ripple-element').length)
Expand Down
13 changes: 2 additions & 11 deletions src/lib/slide-toggle/slide-toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
} from '../core';
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';
import {Observable} from 'rxjs/Observable';
import {Subscription} from 'rxjs/Subscription';

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

/** Subscription to focus-origin changes. */
private _focusOriginSubscription: Subscription;

/** Name value will be applied to the input element if present */
@Input() name: string = null;

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

this._focusOriginSubscription = this._focusOriginMonitor
this._focusOriginMonitor
.monitor(this._inputElement.nativeElement, this._renderer, false)
.subscribe(focusOrigin => this._onInputFocusChange(focusOrigin));
}

ngOnDestroy() {
this._focusOriginMonitor.unmonitor(this._inputElement.nativeElement);

if (this._focusOriginSubscription) {
this._focusOriginSubscription.unsubscribe();
this._focusOriginSubscription = null;
}
this._focusOriginMonitor.stopMonitoring(this._inputElement.nativeElement);
}

/**
Expand Down

0 comments on commit 904c71e

Please sign in to comment.