From 30a9b5574d90da958f305372078ad9c80522641d Mon Sep 17 00:00:00 2001 From: Ibrahim Wassouf Date: Tue, 25 Jul 2023 20:34:48 -0300 Subject: [PATCH] Correct classDef and class grammar Previously, you were allowed to define a class called 'default' but were not allowed to use it because the classStatement grammar expected an alphanum, which did not include the word DEFAULT --- cypress/integration/rendering/flowchart.spec.js | 11 +++++++++++ .../mermaid/src/diagrams/flowchart/parser/flow.jison | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/cypress/integration/rendering/flowchart.spec.js b/cypress/integration/rendering/flowchart.spec.js index 4f6d6478e..6d8b4a49a 100644 --- a/cypress/integration/rendering/flowchart.spec.js +++ b/cypress/integration/rendering/flowchart.spec.js @@ -891,4 +891,15 @@ graph TD { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } ); }); + it('66: apply class called default on node called default', () => { + imgSnapshotTest( + ` + graph TD + classDef default fill:#000,stroke:#000,stroke-width:4px,color:#fff + default --> default2 + class default,default2 default + `, + { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' } + ); + }); }); diff --git a/packages/mermaid/src/diagrams/flowchart/parser/flow.jison b/packages/mermaid/src/diagrams/flowchart/parser/flow.jison index f333702d6..2ed1c7b2e 100644 --- a/packages/mermaid/src/diagrams/flowchart/parser/flow.jison +++ b/packages/mermaid/src/diagrams/flowchart/parser/flow.jison @@ -507,8 +507,8 @@ classDefStatement:CLASSDEF SPACE idString SPACE stylesOpt {$$ = $CLASSDEF;yy.addClass($idString,$stylesOpt);} ; -classStatement:CLASS SPACE idString SPACE alphaNum - {$$ = $CLASS;yy.setClass($idString, $alphaNum);} +classStatement:CLASS SPACE idString\[vertex] SPACE idString\[class] + {$$ = $CLASS;yy.setClass($vertex, $class);} ; clickStatement