Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
fix(menu): remove exception when async loading
Browse files Browse the repository at this point in the history
Fixes #4687.
  • Loading branch information
ThomasBurleson committed Sep 22, 2015
1 parent 0853f2c commit 4f84137
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/components/menu/js/menuServiceProvider.js
Expand Up @@ -410,24 +410,22 @@ function MenuProvider($$interimElementProvider) {
right: boundryNodeRect.right - MENU_EDGE_MARGIN
};

var alignTarget, alignTargetRect, existingOffsets;
var alignTarget, alignTargetRect = { top:0, left : 0, right:0, bottom:0 }, existingOffsets = { top:0, left : 0, right:0, bottom:0 };
var positionMode = opts.mdMenuCtrl.positionMode();

if (positionMode.top == 'target' || positionMode.left == 'target' || positionMode.left == 'target-right') {
// TODO: Allow centering on an arbitrary node, for now center on first menu-item's child
alignTarget = firstVisibleChild();
if (!alignTarget) {
throw Error('Error positioning menu. No visible children.');
if ( alignTarget ) {
// TODO: Allow centering on an arbitrary node, for now center on first menu-item's child
alignTarget = alignTarget.firstElementChild || alignTarget;
alignTarget = alignTarget.querySelector('[md-menu-align-target]') || alignTarget;
alignTargetRect = alignTarget.getBoundingClientRect();

existingOffsets = {
top: parseFloat(containerNode.style.top || 0),
left: parseFloat(containerNode.style.left || 0)
};
}

alignTarget = alignTarget.firstElementChild || alignTarget;
alignTarget = alignTarget.querySelector('[md-menu-align-target]') || alignTarget;
alignTargetRect = alignTarget.getBoundingClientRect();

existingOffsets = {
top: parseFloat(containerNode.style.top || 0),
left: parseFloat(containerNode.style.left || 0)
};
}

var position = {};
Expand Down

0 comments on commit 4f84137

Please sign in to comment.