mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-24 10:46:50 +02:00
#914 Fix for issue identifying node wehen the id of the node starts with a digit
This commit is contained in:
@@ -40,6 +40,20 @@ describe('Flowcart', () => {
|
|||||||
{})
|
{})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should style nodes via a class.', async () => {
|
||||||
|
await imgSnapshotTest(page, `
|
||||||
|
graph TD
|
||||||
|
1A --> 1B
|
||||||
|
1B --> 1C
|
||||||
|
1C --> D
|
||||||
|
1C --> E
|
||||||
|
|
||||||
|
classDef processHead fill:#888888,color:white,font-weight:bold,stroke-width:3px,stroke:#001f3f
|
||||||
|
class 1A,1B,D,E processHead
|
||||||
|
`,
|
||||||
|
{})
|
||||||
|
})
|
||||||
|
|
||||||
it('should render a flowchart full of circles', async () => {
|
it('should render a flowchart full of circles', async () => {
|
||||||
await imgSnapshotTest(page, `
|
await imgSnapshotTest(page, `
|
||||||
graph LR
|
graph LR
|
||||||
@@ -145,6 +159,16 @@ describe('Flowcart', () => {
|
|||||||
{})
|
{})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should render subgraphs with a title startign with a digit', async () => {
|
||||||
|
await imgSnapshotTest(page, `
|
||||||
|
graph TB
|
||||||
|
subgraph 2Two
|
||||||
|
a1-->a2
|
||||||
|
end
|
||||||
|
`,
|
||||||
|
{})
|
||||||
|
})
|
||||||
|
|
||||||
it('should render styled subgraphs', async () => {
|
it('should render styled subgraphs', async () => {
|
||||||
await imgSnapshotTest(page, `
|
await imgSnapshotTest(page, `
|
||||||
graph TB
|
graph TB
|
||||||
|
@@ -61,6 +61,10 @@ export const addVertex = function (_id, text, type, style, classes) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vertices[id].text = txt
|
vertices[id].text = txt
|
||||||
|
} else {
|
||||||
|
if (!vertices[id].text) {
|
||||||
|
vertices[id].text = _id
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (typeof type !== 'undefined') {
|
if (typeof type !== 'undefined') {
|
||||||
vertices[id].type = type
|
vertices[id].type = type
|
||||||
@@ -175,7 +179,9 @@ export const setDirection = function (dir) {
|
|||||||
* @param className Class to add
|
* @param className Class to add
|
||||||
*/
|
*/
|
||||||
export const setClass = function (ids, className) {
|
export const setClass = function (ids, className) {
|
||||||
ids.split(',').forEach(function (id) {
|
ids.split(',').forEach(function (_id) {
|
||||||
|
let id = _id
|
||||||
|
if (_id[0].match(/\d/)) id = 's' + id
|
||||||
if (typeof vertices[id] !== 'undefined') {
|
if (typeof vertices[id] !== 'undefined') {
|
||||||
vertices[id].classes.push(className)
|
vertices[id].classes.push(className)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user