mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-19 15:30:03 +02:00
Merge pull request #1204 from GDFaber/bug/1196_keep_flowchart_label_text_when_style_is_applied
Keep flowchart node label text (if already defined) when a style is applied
This commit is contained in:
@@ -52,7 +52,7 @@ export const addVertex = function(_id, text, type, style, classes) {
|
||||
|
||||
vertices[id].text = txt;
|
||||
} else {
|
||||
if (!vertices[id].text) {
|
||||
if (typeof vertices[id].text === 'undefined') {
|
||||
vertices[id].text = _id;
|
||||
}
|
||||
}
|
||||
|
@@ -86,6 +86,17 @@ describe('[Style] when parsing', () => {
|
||||
expect(vert['T'].styles[1]).toBe('border:1px solid red');
|
||||
});
|
||||
|
||||
it('should keep node label text (if already defined) when a style is applied', function() {
|
||||
const res = flow.parser.parse('graph TD;A(( ));B((Test));C;style A background:#fff;style D border:1px solid red;');
|
||||
|
||||
const vert = flow.parser.yy.getVertices();
|
||||
|
||||
expect(vert['A'].text).toBe('');
|
||||
expect(vert['B'].text).toBe('Test');
|
||||
expect(vert['C'].text).toBe('C');
|
||||
expect(vert['D'].text).toBe('D');
|
||||
});
|
||||
|
||||
it('should be possible to declare a class', function() {
|
||||
const res = flow.parser.parse(
|
||||
'graph TD;classDef exClass background:#bbb,border:1px solid red;'
|
||||
|
Reference in New Issue
Block a user