Added changeset.

This commit is contained in:
saurabhg772244
2025-01-14 15:22:14 +05:30
parent fcb1de915b
commit 3e32332814
3 changed files with 24 additions and 19 deletions

View File

@@ -0,0 +1,5 @@
---
'mermaid': patch
---
`mermaidAPI.getDiagramFromText()` now returns a new different db for each state diagram

View File

@@ -30,12 +30,15 @@ export class StateDb {
#START_TYPE = 'start';
#END_NODE = this.#START_NODE;
#END_TYPE = 'end';
#COLOR_KEYWORD = 'color';
#FILL_KEYWORD = 'fill';
#BG_FILL = 'bgFill';
#STYLECLASS_SEP = ',';
constructor() {
this.clear();
}
/**
* Returns a new list of classes.
* In the future, this can be replaced with a class common to all diagrams.
@@ -54,10 +57,6 @@ export class StateDb {
#rootDoc = [];
#classes = this.#newClassesList(); // style classes defined by a classDef
constructor() {
this.clear();
}
// --------------------------------------
#newDoc = () => {

View File

@@ -848,6 +848,7 @@ graph TD;A--x|text including URL space|B;`)
);
const classDiagram2 = await mermaidAPI.getDiagramFromText(
`stateDiagram
direction TB
[*] --> Still
Still --> [*]
Still --> Moving
@@ -858,7 +859,7 @@ graph TD;A--x|text including URL space|B;`)
expect(classDiagram1.db).not.toBe(classDiagram2.db);
assert(classDiagram1.db instanceof StateDb);
assert(classDiagram2.db instanceof StateDb);
expect(classDiagram2.db.getDirection()).not.toEqual(classDiagram2.db.getDirection());
expect(classDiagram1.db.getDirection()).not.toEqual(classDiagram2.db.getDirection());
});
});