Skip to content

Commit

Permalink
bug/#3251_linkStyle-can't-specify-ids Fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
RounakJoshi09 committed Oct 9, 2023
1 parent 12a4707 commit cdb4639
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/mermaid/src/diagrams/flowchart/flowDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ export const updateLinkInterpolate = function (positions, interp) {
*/
export const updateLink = function (positions, style) {
positions.forEach(function (pos) {
if (pos >= edges.length) {
let error = new Error(

Check warning on line 196 in packages/mermaid/src/diagrams/flowchart/flowDb.js

View check run for this annotation

Codecov / codecov/patch

packages/mermaid/src/diagrams/flowchart/flowDb.js#L196

Added line #L196 was not covered by tests
`Incorrect index ${pos} of linkStyle. (Help: Index must be from 0 to ${edges.length - 1})`
);
throw error;

Check warning on line 199 in packages/mermaid/src/diagrams/flowchart/flowDb.js

View check run for this annotation

Codecov / codecov/patch

packages/mermaid/src/diagrams/flowchart/flowDb.js#L199

Added line #L199 was not covered by tests
}
if (pos === 'default') {
edges.defaultStyle = style;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,14 @@ describe('[Style] when parsing', () => {
expect(edges[0].type).toBe('arrow_point');
});

it('should handle style definitions within number of edges', function () {
const res = flow.parser.parse('graph TD\n' + 'A-->B\n' + 'linkStyle 0 stroke-width:1px;');

const edges = flow.parser.yy.getEdges();

expect(edges[0].style[0]).toBe('stroke-width:1px');
});

it('should handle multi-numbered style definitions with more then 1 digit in a row', function () {
const res = flow.parser.parse(
'graph TD\n' +
Expand Down

0 comments on commit cdb4639

Please sign in to comment.