@@ -490,26 +490,21 @@ export class MatSlider extends _MatSliderMixinBase
490
490
private _lastPointerEvent : MouseEvent | TouchEvent | null ;
491
491
492
492
/** Used to subscribe to global move and end events */
493
- protected _document ? : Document ;
493
+ protected _document : Document ;
494
494
495
495
constructor ( elementRef : ElementRef ,
496
496
private _focusMonitor : FocusMonitor ,
497
497
private _changeDetectorRef : ChangeDetectorRef ,
498
498
@Optional ( ) private _dir : Directionality ,
499
499
@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 ) {
506
503
super ( elementRef ) ;
507
-
508
- this . _document = document ;
509
-
504
+ this . _document = _document ;
510
505
this . tabIndex = parseInt ( tabIndex ) || 0 ;
511
506
512
- this . _runOutsizeZone ( ( ) => {
507
+ _ngZone . runOutsideAngular ( ( ) => {
513
508
const element = elementRef . nativeElement ;
514
509
element . addEventListener ( 'mousedown' , this . _pointerDown , activeEventOptions ) ;
515
510
element . addEventListener ( 'touchstart' , this . _pointerDown , activeEventOptions ) ;
@@ -629,7 +624,7 @@ export class MatSlider extends _MatSliderMixinBase
629
624
return ;
630
625
}
631
626
632
- this . _runInsideZone ( ( ) => {
627
+ this . _ngZone . run ( ( ) => {
633
628
const oldValue = this . value ;
634
629
const pointerPosition = getPointerPositionOnPage ( event ) ;
635
630
this . _isSliding = true ;
@@ -700,7 +695,7 @@ export class MatSlider extends _MatSliderMixinBase
700
695
701
696
/** Use defaultView of injected document if available or fallback to global window reference */
702
697
private _getWindow ( ) : Window {
703
- return this . _document ? .defaultView || window ;
698
+ return this . _document . defaultView || window ;
704
699
}
705
700
706
701
/**
@@ -712,17 +707,14 @@ export class MatSlider extends _MatSliderMixinBase
712
707
// Note that we bind the events to the `document`, because it allows us to capture
713
708
// drag cancel events where the user's pointer is outside the browser window.
714
709
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 ) ;
726
718
}
727
719
728
720
const window = this . _getWindow ( ) ;
@@ -735,14 +727,11 @@ export class MatSlider extends _MatSliderMixinBase
735
727
/** Removes any global event listeners that we may have added. */
736
728
private _removeGlobalEvents ( ) {
737
729
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 ) ;
746
735
747
736
const window = this . _getWindow ( ) ;
748
737
@@ -869,18 +858,6 @@ export class MatSlider extends _MatSliderMixinBase
869
858
this . _elementRef . nativeElement . blur ( ) ;
870
859
}
871
860
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
-
884
861
/**
885
862
* Sets the model value. Implemented as part of ControlValueAccessor.
886
863
* @param value
0 commit comments