mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
chore: Cleanup dataFetcher
This commit is contained in:
parent
b1b5ad3c9b
commit
3c6ae36611
@ -35,7 +35,7 @@ import {
|
||||
} from './stateCommon.js';
|
||||
|
||||
// List of nodes created from the parsed diagram statement items
|
||||
let nodeDb = {};
|
||||
let nodeDb = new Map();
|
||||
|
||||
let graphItemCount = 0; // used to construct ids, etc.
|
||||
|
||||
@ -104,7 +104,6 @@ const setupDoc = (parentParsedItem, doc, diagramStates, nodes, edges, altFlag, l
|
||||
look,
|
||||
};
|
||||
edges.push(edgeData);
|
||||
//g.setEdge(item.state1.id, item.state2.id, edgeData, graphItemCount);
|
||||
graphItemCount++;
|
||||
}
|
||||
break;
|
||||
@ -229,6 +228,7 @@ function getStylesFromDbInfo(dbInfoItem) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const dataFetcher = (
|
||||
parent,
|
||||
parsedItem,
|
||||
@ -259,17 +259,17 @@ export const dataFetcher = (
|
||||
}
|
||||
|
||||
// Add the node to our list (nodeDb)
|
||||
if (!nodeDb[itemId]) {
|
||||
nodeDb[itemId] = {
|
||||
if (!nodeDb.get(itemId)) {
|
||||
nodeDb.set(itemId, {
|
||||
id: itemId,
|
||||
shape,
|
||||
description: common.sanitizeText(itemId, getConfig()),
|
||||
cssClasses: `${classStr} ${CSS_DIAGRAM_STATE}`,
|
||||
cssStyles: style,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
const newNode = nodeDb[itemId];
|
||||
const newNode = nodeDb.get(itemId);
|
||||
|
||||
// Save data for description and group so that for instance a statement without description overwrites
|
||||
// one with description @todo TODO What does this mean? If important, add a test for it
|
||||
@ -305,7 +305,6 @@ export const dataFetcher = (
|
||||
} else {
|
||||
newNode.shape = SHAPE_STATE;
|
||||
}
|
||||
//newNode.shape = SHAPE_STATE;
|
||||
}
|
||||
|
||||
// group
|
||||
@ -315,12 +314,7 @@ export const dataFetcher = (
|
||||
newNode.isGroup = true;
|
||||
newNode.dir = getDir(parsedItem);
|
||||
newNode.shape = parsedItem.type === DIVIDER_TYPE ? SHAPE_DIVIDER : SHAPE_GROUP;
|
||||
newNode.cssClasses =
|
||||
newNode.cssClasses +
|
||||
' ' +
|
||||
CSS_DIAGRAM_CLUSTER +
|
||||
' ' +
|
||||
(altFlag ? CSS_DIAGRAM_CLUSTER_ALT : '');
|
||||
newNode.cssClasses = `${newNode.cssClasses} ${CSS_DIAGRAM_CLUSTER} ${altFlag ? CSS_DIAGRAM_CLUSTER_ALT : ''}`;
|
||||
}
|
||||
|
||||
// This is what will be added to the graph
|
||||
@ -436,6 +430,6 @@ export const dataFetcher = (
|
||||
};
|
||||
|
||||
export const reset = () => {
|
||||
nodeDb = {};
|
||||
nodeDb.clear();
|
||||
graphItemCount = 0;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user