mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-14 22:09:29 +02:00
Merge pull request #6739 from kriss-u/bug/6681_td_tb_behavior
fix: trim the direction string in flowchart
This commit is contained in:
5
.changeset/smart-humans-cover.md
Normal file
5
.changeset/smart-humans-cover.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'mermaid': patch
|
||||
---
|
||||
|
||||
fix: Update flowchart direction TD's behavior to be the same as TB
|
@@ -165,3 +165,20 @@ describe('flow db getData', () => {
|
||||
expect(edges[3].curve).toBe('stepBefore');
|
||||
});
|
||||
});
|
||||
|
||||
describe('flow db direction', () => {
|
||||
let flowDb: FlowDB;
|
||||
beforeEach(() => {
|
||||
flowDb = new FlowDB();
|
||||
});
|
||||
|
||||
it('should set direction to TB when TD is set', () => {
|
||||
flowDb.setDirection('TD');
|
||||
expect(flowDb.getDirection()).toBe('TB');
|
||||
});
|
||||
|
||||
it('should correctly set direction irrespective of leading spaces', () => {
|
||||
flowDb.setDirection(' TD');
|
||||
expect(flowDb.getDirection()).toBe('TB');
|
||||
});
|
||||
});
|
||||
|
@@ -406,7 +406,8 @@ You have to call mermaid.initialize.`
|
||||
*
|
||||
*/
|
||||
public setDirection(dir: string) {
|
||||
this.direction = dir;
|
||||
this.direction = dir.trim();
|
||||
|
||||
if (/.*</.exec(this.direction)) {
|
||||
this.direction = 'RL';
|
||||
}
|
||||
|
Reference in New Issue
Block a user