From 44561f57d399b978789975cf4f947ab43aef01b2 Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Fri, 13 Sep 2024 14:18:46 +0200 Subject: [PATCH] Moving case check to parsing --- packages/mermaid/src/diagrams/flowchart/flowDb.ts | 4 ++++ .../mermaid/src/rendering-util/rendering-elements/nodes.js | 4 +--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/mermaid/src/diagrams/flowchart/flowDb.ts b/packages/mermaid/src/diagrams/flowchart/flowDb.ts index cf744e5e4..b47daee11 100644 --- a/packages/mermaid/src/diagrams/flowchart/flowDb.ts +++ b/packages/mermaid/src/diagrams/flowchart/flowDb.ts @@ -133,6 +133,10 @@ export const addVertex = function ( } // console.log('yamlData', yamlData); const doc = yaml.load(yamlData, { schema: yaml.JSON_SCHEMA }) as NodeMetaData; + if (doc.shape && doc.shape !== doc.shape.toLowerCase()) { + throw new Error(`No such shape: ${node.shape}. Shape names should be lowercase.`); + } + // console.log('yamlData doc', doc); if (doc?.shape) { vertex.type = doc?.shape; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/nodes.js b/packages/mermaid/src/rendering-util/rendering-elements/nodes.js index 960d93016..55deb1b78 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/nodes.js +++ b/packages/mermaid/src/rendering-util/rendering-elements/nodes.js @@ -321,9 +321,7 @@ export const insertNode = async (elem, node, renderOptions) => { if (!shapes[node.shape]) { throw new Error(`No such shape: ${node.shape}. Please check your syntax.`); } - if (node.shape !== node.shape.toLowerCase()) { - throw new Error(`No such shape: ${node.shape}. Shape names should be lowercase.`); - } + if (node.link) { // Add link when appropriate let target;