@@ -490,26 +490,21 @@ export class MatSlider extends _MatSliderMixinBase
490490 private _lastPointerEvent : MouseEvent | TouchEvent | null ;
491491
492492 /** Used to subscribe to global move and end events */
493- protected _document ? : Document ;
493+ protected _document : Document ;
494494
495495 constructor ( elementRef : ElementRef ,
496496 private _focusMonitor : FocusMonitor ,
497497 private _changeDetectorRef : ChangeDetectorRef ,
498498 @Optional ( ) private _dir : Directionality ,
499499 @Attribute ( 'tabindex' ) tabIndex : string ,
500- // @breaking -change 8.0.0 `_animationMode` parameter to be made required.
501- @Optional ( ) @Inject ( ANIMATION_MODULE_TYPE ) public _animationMode ?: string ,
502- // @breaking -change 9.0.0 `_ngZone` parameter to be made required.
503- private _ngZone ?: NgZone ,
504- /** @breaking -change 11.0.0 make document required */
505- @Optional ( ) @Inject ( DOCUMENT ) document ?: any ) {
500+ private _ngZone : NgZone ,
501+ @Inject ( DOCUMENT ) _document : any ,
502+ @Optional ( ) @Inject ( ANIMATION_MODULE_TYPE ) public _animationMode ?: string ) {
506503 super ( elementRef ) ;
507-
508- this . _document = document ;
509-
504+ this . _document = _document ;
510505 this . tabIndex = parseInt ( tabIndex ) || 0 ;
511506
512- this . _runOutsizeZone ( ( ) => {
507+ _ngZone . runOutsideAngular ( ( ) => {
513508 const element = elementRef . nativeElement ;
514509 element . addEventListener ( 'mousedown' , this . _pointerDown , activeEventOptions ) ;
515510 element . addEventListener ( 'touchstart' , this . _pointerDown , activeEventOptions ) ;
@@ -629,7 +624,7 @@ export class MatSlider extends _MatSliderMixinBase
629624 return ;
630625 }
631626
632- this . _runInsideZone ( ( ) => {
627+ this . _ngZone . run ( ( ) => {
633628 const oldValue = this . value ;
634629 const pointerPosition = getPointerPositionOnPage ( event ) ;
635630 this . _isSliding = true ;
@@ -700,7 +695,7 @@ export class MatSlider extends _MatSliderMixinBase
700695
701696 /** Use defaultView of injected document if available or fallback to global window reference */
702697 private _getWindow ( ) : Window {
703- return this . _document ? .defaultView || window ;
698+ return this . _document . defaultView || window ;
704699 }
705700
706701 /**
@@ -712,17 +707,14 @@ export class MatSlider extends _MatSliderMixinBase
712707 // Note that we bind the events to the `document`, because it allows us to capture
713708 // drag cancel events where the user's pointer is outside the browser window.
714709 const document = this . _document ;
715-
716- if ( typeof document !== 'undefined' && document ) {
717- const isTouch = isTouchEvent ( triggerEvent ) ;
718- const moveEventName = isTouch ? 'touchmove' : 'mousemove' ;
719- const endEventName = isTouch ? 'touchend' : 'mouseup' ;
720- document . addEventListener ( moveEventName , this . _pointerMove , activeEventOptions ) ;
721- document . addEventListener ( endEventName , this . _pointerUp , activeEventOptions ) ;
722-
723- if ( isTouch ) {
724- document . addEventListener ( 'touchcancel' , this . _pointerUp , activeEventOptions ) ;
725- }
710+ const isTouch = isTouchEvent ( triggerEvent ) ;
711+ const moveEventName = isTouch ? 'touchmove' : 'mousemove' ;
712+ const endEventName = isTouch ? 'touchend' : 'mouseup' ;
713+ document . addEventListener ( moveEventName , this . _pointerMove , activeEventOptions ) ;
714+ document . addEventListener ( endEventName , this . _pointerUp , activeEventOptions ) ;
715+
716+ if ( isTouch ) {
717+ document . addEventListener ( 'touchcancel' , this . _pointerUp , activeEventOptions ) ;
726718 }
727719
728720 const window = this . _getWindow ( ) ;
@@ -735,14 +727,11 @@ export class MatSlider extends _MatSliderMixinBase
735727 /** Removes any global event listeners that we may have added. */
736728 private _removeGlobalEvents ( ) {
737729 const document = this . _document ;
738-
739- if ( typeof document !== 'undefined' && document ) {
740- document . removeEventListener ( 'mousemove' , this . _pointerMove , activeEventOptions ) ;
741- document . removeEventListener ( 'mouseup' , this . _pointerUp , activeEventOptions ) ;
742- document . removeEventListener ( 'touchmove' , this . _pointerMove , activeEventOptions ) ;
743- document . removeEventListener ( 'touchend' , this . _pointerUp , activeEventOptions ) ;
744- document . removeEventListener ( 'touchcancel' , this . _pointerUp , activeEventOptions ) ;
745- }
730+ document . removeEventListener ( 'mousemove' , this . _pointerMove , activeEventOptions ) ;
731+ document . removeEventListener ( 'mouseup' , this . _pointerUp , activeEventOptions ) ;
732+ document . removeEventListener ( 'touchmove' , this . _pointerMove , activeEventOptions ) ;
733+ document . removeEventListener ( 'touchend' , this . _pointerUp , activeEventOptions ) ;
734+ document . removeEventListener ( 'touchcancel' , this . _pointerUp , activeEventOptions ) ;
746735
747736 const window = this . _getWindow ( ) ;
748737
@@ -869,18 +858,6 @@ export class MatSlider extends _MatSliderMixinBase
869858 this . _elementRef . nativeElement . blur ( ) ;
870859 }
871860
872- /** Runs a callback inside of the NgZone, if possible. */
873- private _runInsideZone ( fn : ( ) => any ) {
874- // @breaking -change 9.0.0 Remove this function once `_ngZone` is a required parameter.
875- this . _ngZone ? this . _ngZone . run ( fn ) : fn ( ) ;
876- }
877-
878- /** Runs a callback outside of the NgZone, if possible. */
879- private _runOutsizeZone ( fn : ( ) => any ) {
880- // @breaking -change 9.0.0 Remove this function once `_ngZone` is a required parameter.
881- this . _ngZone ? this . _ngZone . runOutsideAngular ( fn ) : fn ( ) ;
882- }
883-
884861 /**
885862 * Sets the model value. Implemented as part of ControlValueAccessor.
886863 * @param value
0 commit comments