@@ -206,9 +206,7 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
206
206
@Input ( 'matTooltip' )
207
207
get message ( ) { return this . _message ; }
208
208
set message ( value : string ) {
209
- if ( this . _message ) {
210
- this . _ariaDescriber . removeDescription ( this . _elementRef . nativeElement , this . _message ) ;
211
- }
209
+ this . _ariaDescriber . removeDescription ( this . _elementRef . nativeElement , this . _message ) ;
212
210
213
211
// If the message is not a string (e.g. number), convert it to a string and trim it.
214
212
this . _message = value != null ? `${ value } ` . trim ( ) : '' ;
@@ -560,7 +558,7 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
560
558
561
559
// The mouse events shouldn't be bound on mobile devices, because they can prevent the
562
560
// first tap from firing its click event or can cause the tooltip to open for clicks.
563
- if ( ! this . _platform . IOS && ! this . _platform . ANDROID ) {
561
+ if ( this . _platformSupportsMouseEvents ( ) ) {
564
562
this . _passiveListeners
565
563
. push ( [ 'mouseenter' , ( ) => {
566
564
this . _setupPointerExitEventsIfNeeded ( ) ;
@@ -579,7 +577,7 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
579
577
} ] ) ;
580
578
}
581
579
582
- this . _hookupListeners ( this . _passiveListeners ) ;
580
+ this . _addListeners ( this . _passiveListeners ) ;
583
581
}
584
582
585
583
private _setupPointerExitEventsIfNeeded ( ) {
@@ -589,7 +587,7 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
589
587
this . _pointerExitEventsInitialized = true ;
590
588
591
589
const exitListeners : ( readonly [ string , EventListenerOrEventListenerObject ] ) [ ] = [ ] ;
592
- if ( ! this . _platform . IOS && ! this . _platform . ANDROID ) {
590
+ if ( this . _platformSupportsMouseEvents ( ) ) {
593
591
exitListeners . push ( [ 'mouseleave' , ( ) => this . hide ( ) ] ) ;
594
592
} else if ( this . touchGestures !== 'off' ) {
595
593
this . _disableNativeGesturesIfNecessary ( ) ;
@@ -604,11 +602,11 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
604
602
) ;
605
603
}
606
604
607
- this . _hookupListeners ( exitListeners ) ;
605
+ this . _addListeners ( exitListeners ) ;
608
606
this . _passiveListeners . push ( ...exitListeners ) ;
609
607
}
610
608
611
- private _hookupListeners (
609
+ private _addListeners (
612
610
listeners : ReadonlyArray < readonly [ string , EventListenerOrEventListenerObject ] > ) {
613
611
listeners . forEach ( ( [ event , listener ] ) => {
614
612
this . _elementRef . nativeElement . addEventListener ( event , listener , passiveListenerOptions ) ;
@@ -752,6 +750,10 @@ export class TooltipComponent implements OnDestroy {
752
750
this . _onHide . complete ( ) ;
753
751
}
754
752
753
+ private _platformSupportsMouseEvents ( ) {
754
+ return ! this . _platform . IOS && ! this . _platform . ANDROID ;
755
+ }
756
+
755
757
_animationStart ( ) {
756
758
this . _closeOnInteraction = false ;
757
759
}
0 commit comments