This repository was archived by the owner on Sep 5, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -179,8 +179,6 @@ function MenuDirective($mdUtil) {
179
179
templateElement . addClass ( 'md-menu' ) ;
180
180
181
181
var triggerEl = templateElement . children ( ) [ 0 ] ;
182
- var contentEl = templateElement . children ( ) [ 1 ] ;
183
-
184
182
var prefixer = $mdUtil . prefixer ( ) ;
185
183
186
184
if ( ! prefixer . hasAttribute ( triggerEl , 'ng-click' ) ) {
@@ -198,8 +196,8 @@ function MenuDirective($mdUtil) {
198
196
throw Error ( INVALID_PREFIX + 'Expected the menu to have a trigger element.' ) ;
199
197
}
200
198
201
- if ( ! contentEl || contentEl . nodeName !== 'MD-MENU-CONTENT' ) {
202
- throw Error ( INVALID_PREFIX + 'Expected the menu to contain a `md-menu-content` element.' ) ;
199
+ if ( templateElement . children ( ) . length !== 2 ) {
200
+ throw Error ( INVALID_PREFIX + 'Expected two children elements. The second element must have a `md-menu-content` element.' ) ;
203
201
}
204
202
205
203
// Default element for ARIA attributes has the ngClick or ngMouseenter expression
Original file line number Diff line number Diff line change @@ -51,6 +51,21 @@ describe('material.components.menu', function() {
51
51
expect ( createInvalidMenu ) . toThrow ( ) ;
52
52
} ) ) ;
53
53
54
+ it ( 'nested md-menu-content should be allowed' , inject ( function ( $compile , $rootScope ) {
55
+ function createValidMenu ( ) {
56
+ $compile (
57
+ '<md-menu>' +
58
+ ' <button ng-click="null">Trigger Element</button>' +
59
+ ' <some-custom-element>' +
60
+ ' <md-menu-content>Menu Content</md-menu-content>' +
61
+ ' </some-custom-element>' +
62
+ '</md-menu>'
63
+ ) ( $rootScope ) ;
64
+ }
65
+
66
+ expect ( createValidMenu ) . not . toThrow ( ) ;
67
+ } ) ) ;
68
+
54
69
it ( 'specifies button type' , inject ( function ( $compile , $rootScope ) {
55
70
var menu = setup ( ) [ 0 ] ;
56
71
expect ( menu . firstElementChild . getAttribute ( 'type' ) ) . toBe ( 'button' ) ;
You can’t perform that action at this time.
0 commit comments