Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/components/menu/js/menuDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,6 @@ function MenuDirective($mdUtil) {
templateElement.addClass('md-menu');

var triggerEl = templateElement.children()[0];
var contentEl = templateElement.children()[1];

var prefixer = $mdUtil.prefixer();

if (!prefixer.hasAttribute(triggerEl, 'ng-click')) {
Expand All @@ -198,8 +196,8 @@ function MenuDirective($mdUtil) {
throw Error(INVALID_PREFIX + 'Expected the menu to have a trigger element.');
}

if (!contentEl || contentEl.nodeName !== 'MD-MENU-CONTENT') {
throw Error(INVALID_PREFIX + 'Expected the menu to contain a `md-menu-content` element.');
if (templateElement.children().length !== 2) {
throw Error(INVALID_PREFIX + 'Expected two children elements. The second element must have a `md-menu-content` element.');
}

// Default element for ARIA attributes has the ngClick or ngMouseenter expression
Expand Down
15 changes: 15 additions & 0 deletions src/components/menu/menu.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ describe('material.components.menu', function() {
expect(createInvalidMenu).toThrow();
}));

it('nested md-menu-content should be allowed', inject(function($compile, $rootScope) {
function createValidMenu() {
$compile(
'<md-menu>' +
' <button ng-click="null">Trigger Element</button>' +
' <some-custom-element>' +
' <md-menu-content>Menu Content</md-menu-content>' +
' </some-custom-element>' +
'</md-menu>'
)($rootScope);
}

expect(createValidMenu).not.toThrow();
}));

it('specifies button type', inject(function($compile, $rootScope) {
var menu = setup()[0];
expect(menu.firstElementChild.getAttribute('type')).toBe('button');
Expand Down