@@ -16,6 +16,7 @@ import {
16
16
Inject ,
17
17
Optional ,
18
18
Input ,
19
+ HostListener ,
19
20
} from '@angular/core' ;
20
21
import {
21
22
CanDisable , CanDisableCtor ,
@@ -50,8 +51,6 @@ export const _MatMenuItemMixinBase: CanDisableRippleCtor & CanDisableCtor & type
50
51
'[attr.tabindex]' : '_getTabIndex()' ,
51
52
'[attr.aria-disabled]' : 'disabled.toString()' ,
52
53
'[attr.disabled]' : 'disabled || null' ,
53
- '(click)' : '_checkDisabled($event)' ,
54
- '(mouseenter)' : '_handleMouseEnter()' ,
55
54
} ,
56
55
changeDetection : ChangeDetectionStrategy . OnPush ,
57
56
encapsulation : ViewEncapsulation . None ,
@@ -129,6 +128,12 @@ export class MatMenuItem extends _MatMenuItemMixinBase
129
128
}
130
129
131
130
/** Prevents the default element actions if it is disabled. */
131
+ // We have to use a `HostListener` here in order to support both Ivy and ViewEngine.
132
+ // In Ivy the `host` bindings will be merged when this class is extended, whereas in
133
+ // ViewEngine they're overwritte.
134
+ // TODO(crisbeto): we move this back into `host` once Ivy is turned on by default.
135
+ // tslint:disable-next-line:no-host-decorator-in-concrete
136
+ @HostListener ( 'click' , [ '$event' ] )
132
137
_checkDisabled ( event : Event ) : void {
133
138
if ( this . disabled ) {
134
139
event . preventDefault ( ) ;
@@ -137,6 +142,12 @@ export class MatMenuItem extends _MatMenuItemMixinBase
137
142
}
138
143
139
144
/** Emits to the hover stream. */
145
+ // We have to use a `HostListener` here in order to support both Ivy and ViewEngine.
146
+ // In Ivy the `host` bindings will be merged when this class is extended, whereas in
147
+ // ViewEngine they're overwritte.
148
+ // TODO(crisbeto): we move this back into `host` once Ivy is turned on by default.
149
+ // tslint:disable-next-line:no-host-decorator-in-concrete
150
+ @HostListener ( 'mouseenter' )
140
151
_handleMouseEnter ( ) {
141
152
this . _hovered . next ( this ) ;
142
153
}
@@ -164,4 +175,3 @@ export class MatMenuItem extends _MatMenuItemMixinBase
164
175
}
165
176
166
177
}
167
-
0 commit comments