From 537512fb2718813514ea3cd4ebba0a4762836a3a Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Fri, 9 Aug 2024 14:54:01 +0200 Subject: [PATCH] #5237 Replace generic object with Map --- .../src/rendering-util/rendering-elements/clusters.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/mermaid/src/rendering-util/rendering-elements/clusters.js b/packages/mermaid/src/rendering-util/rendering-elements/clusters.js index 143d5e0b1f..5e475f110c 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/clusters.js +++ b/packages/mermaid/src/rendering-util/rendering-elements/clusters.js @@ -357,12 +357,12 @@ const shapes = { divider, }; -let clusterElems = {}; +let clusterElems = new Map(); export const insertCluster = (elem, node) => { const shape = node.shape || 'rect'; const cluster = shapes[shape](elem, node); - clusterElems[node.id] = cluster; + clusterElems.set(node.id, cluster); return cluster; }; export const getClusterTitleWidth = (elem, node) => { @@ -374,7 +374,7 @@ export const getClusterTitleWidth = (elem, node) => { }; export const clear = () => { - clusterElems = {}; + clusterElems = new Map(); }; export const positionCluster = (node) => { @@ -390,8 +390,8 @@ export const positionCluster = (node) => { ', ' + node?.height + ')', - clusterElems[node.id] + clusterElems.get(node.id) ); - const el = clusterElems[node.id]; + const el = clusterElems.get(node.id); el.cluster.attr('transform', 'translate(' + node.x + ', ' + node.y + ')'); };