Skip to content

Commit

Permalink
No infinite loop for path lookups
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-grant-work committed Jul 5, 2022
1 parent c869edb commit 74696f0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/core/src/common/menu/menu-model-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,14 @@ export class MenuModelRegistry {
*/
getPath(node: MenuNode): MenuPath | undefined {
const identifiers = [];
const visited: MenuNode[] = [];
let next: MenuNode | undefined = node;

while (next) {
while (next && !visited.includes(next)) {
if (next === this.root) {
return identifiers.reverse();
}
visited.push(next);
identifiers.push(next.id);
next = next.parent;
}
Expand Down

0 comments on commit 74696f0

Please sign in to comment.