mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-20 16:56:41 +02:00
#5237 Fix for incorrect handling of self loops with elk layout
This commit is contained in:
@@ -7,6 +7,11 @@ export const findCommonAncestor = (id1: string, id2: string, treeData: TreeData)
|
|||||||
const { parentById } = treeData;
|
const { parentById } = treeData;
|
||||||
const visited = new Set();
|
const visited = new Set();
|
||||||
let currentId = id1;
|
let currentId = id1;
|
||||||
|
|
||||||
|
if (id1 === id2) {
|
||||||
|
return parentById[id1] || 'root';
|
||||||
|
}
|
||||||
|
|
||||||
while (currentId) {
|
while (currentId) {
|
||||||
visited.add(currentId);
|
visited.add(currentId);
|
||||||
if (currentId === id2) {
|
if (currentId === id2) {
|
||||||
|
Reference in New Issue
Block a user