@@ -145,7 +145,11 @@ function MenuDirective($mdMenu) {
145
145
146
146
function compile ( templateElement ) {
147
147
templateElement . addClass ( 'md-menu' ) ;
148
- templateElement . children ( ) . eq ( 0 ) . attr ( 'aria-haspopup' , 'true' ) ;
148
+ var triggerElement = templateElement . children ( ) [ 0 ] ;
149
+ if ( ! triggerElement . hasAttribute ( 'ng-click' ) ) {
150
+ triggerElement = triggerElement . querySelector ( '[ng-click]' ) ;
151
+ }
152
+ triggerElement && triggerElement . setAttribute ( 'aria-haspopup' , 'true' ) ;
149
153
if ( templateElement . children ( ) . length != 2 ) {
150
154
throw Error ( 'Invalid HTML for md-menu. Expected two children elements.' ) ;
151
155
}
@@ -176,17 +180,19 @@ function MenuController($mdMenu, $attrs, $element, $scope) {
176
180
177
181
var menuContainer ;
178
182
var ctrl = this ;
183
+ var triggerElement ;
179
184
180
185
// Called by our linking fn to provide access to the menu-content
181
186
// element removed during link
182
187
this . init = function ( setMenuContainer ) {
183
188
menuContainer = setMenuContainer ;
189
+ triggerElement = $element [ 0 ] . querySelector ( '[ng-click]' ) ;
184
190
} ;
185
191
186
192
// Uses the $mdMenu interim element service to open the menu contents
187
193
this . open = function openMenu ( ) {
188
194
ctrl . isOpen = true ;
189
- $element . attr ( 'aria-expanded' , 'true' ) ;
195
+ triggerElement . setAttribute ( 'aria-expanded' , 'true' ) ;
190
196
$mdMenu . show ( {
191
197
mdMenuCtrl : ctrl ,
192
198
element : menuContainer ,
@@ -199,7 +205,7 @@ function MenuController($mdMenu, $attrs, $element, $scope) {
199
205
// Use the $mdMenu interim element service to close the menu contents
200
206
this . close = function closeMenu ( skipFocus ) {
201
207
ctrl . isOpen = false ;
202
- $element . attr ( 'aria-expanded' , 'false' ) ;
208
+ triggerElement . setAttribute ( 'aria-expanded' , 'false' ) ;
203
209
$mdMenu . hide ( ) ;
204
210
205
211
if ( ! skipFocus ) {
0 commit comments