Skip to content

Commit e446bef

Browse files
committed
Fix prerender test issue
1 parent 4118f4e commit e446bef

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/lib/slider/slider.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,9 @@ export class MdSlider extends _MdSliderMixinBase
388388
/** The value of the slider when the slide start event fires. */
389389
private _valueOnSlideStart: number | null;
390390

391+
/** Whether the component has been initialized. */
392+
private _initialized = false;
393+
391394
/** Reference to the inner slider wrapper element. */
392395
@ViewChild('sliderWrapper') private _sliderWrapper: ElementRef;
393396

@@ -414,10 +417,16 @@ export class MdSlider extends _MdSliderMixinBase
414417
.monitor(this._elementRef.nativeElement, renderer, true)
415418
.subscribe((origin: FocusOrigin) => {
416419
this._isActive = !!origin && origin !== 'keyboard';
417-
this._changeDetectorRef.detectChanges();
420+
if (this._initialized) {
421+
this._changeDetectorRef.detectChanges();
422+
}
418423
});
419-
if (_dir) {
420-
_dir.change.subscribe(() => this._changeDetectorRef.markForCheck());
424+
}
425+
426+
ngOnInit() {
427+
this._initialized = true;
428+
if (this._dir) {
429+
this._dir.change.subscribe(() => this._changeDetectorRef.markForCheck());
421430
}
422431
}
423432

0 commit comments

Comments
 (0)