diff --git a/packages/mermaid/src/diagrams/flowchart/flowDb.ts b/packages/mermaid/src/diagrams/flowchart/flowDb.ts index 7558336c0..8c4b45b42 100644 --- a/packages/mermaid/src/diagrams/flowchart/flowDb.ts +++ b/packages/mermaid/src/diagrams/flowchart/flowDb.ts @@ -729,14 +729,12 @@ export const destructLink = (_str: string, _startStr: string) => { // Todo optimizer this by caching existing nodes const exists = (allSgs: FlowSubGraph[], _id: string) => { - let res = false; - allSgs.forEach((sg) => { - const pos = sg.nodes.indexOf(_id); - if (pos >= 0) { - res = true; + for (const sg of allSgs) { + if (sg.nodes.indexOf(_id) >= 0) { + return true; } - }); - return res; + } + return false; }; /** * Deletes an id from all subgraphs @@ -830,14 +828,11 @@ function getCompiledStyles(classDefs: string[]) { let compiledStyles: string[] = []; for (const customClass of classDefs) { const cssClass = classes.get(customClass); - // log.debug('IPI cssClass in flowDb', cssClass); - if (cssClass) { - if (cssClass.styles) { - compiledStyles = [...compiledStyles, ...(cssClass.styles ?? [])].map((s) => s.trim()); - } - if (cssClass.textStyles) { - compiledStyles = [...compiledStyles, ...(cssClass.textStyles ?? [])].map((s) => s.trim()); - } + if (cssClass?.styles) { + compiledStyles = [...compiledStyles, ...(cssClass.styles ?? [])].map((s) => s.trim()); + } + if (cssClass?.textStyles) { + compiledStyles = [...compiledStyles, ...(cssClass.textStyles ?? [])].map((s) => s.trim()); } } return compiledStyles; @@ -858,9 +853,9 @@ export const getData = () => { if (subGraph.nodes.length > 0) { subGraphDB.set(subGraph.id, true); } - subGraph.nodes.forEach((id) => { + for (const id of subGraph.nodes) { parentDB.set(id, subGraph.id); - }); + } } // Data is setup, add the nodes @@ -917,8 +912,6 @@ export const getData = () => { edges.push(edge); }); - // log.debug('IPI nodes', JSON.stringify(nodes, null, 2)); - return { nodes, edges, other: {}, config }; };