From 21aa8c5f15ce3b0d5ed4fba6850cea3f37d53e68 Mon Sep 17 00:00:00 2001 From: knsv Date: Tue, 3 Sep 2019 11:31:47 -0700 Subject: [PATCH] #922 Fix for click binding on nodes with ids starting with a number --- e2e/platform/click.html | 6 ++++++ src/diagrams/flowchart/flowDb.js | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/e2e/platform/click.html b/e2e/platform/click.html index eda2f6942..2a018fd72 100644 --- a/e2e/platform/click.html +++ b/e2e/platform/click.html @@ -13,6 +13,12 @@ click Function clickByFlow "Add a div" click URL "https://mermaidjs.github.io/" "Visit mermaid docs" +
+ graph TB + 1Function-->2URL + click 1Function clickByFlow "Add a div" + click 2URL "https://mermaidjs.github.io/" "Visit mermaid docs" +
gantt diff --git a/src/diagrams/flowchart/flowDb.js b/src/diagrams/flowchart/flowDb.js index cd4d4dae5..b9e397eca 100644 --- a/src/diagrams/flowchart/flowDb.js +++ b/src/diagrams/flowchart/flowDb.js @@ -200,7 +200,9 @@ const setTooltip = function (ids, tooltip) { }) } -const setClickFun = function (id, functionName) { +const setClickFun = function (_id, functionName) { + let id = _id + if (_id[0].match(/\d/)) id = 's' + id if (config.securityLevel !== 'loose') { return } @@ -226,7 +228,9 @@ const setClickFun = function (id, functionName) { * @param tooltip Tooltip for the clickable element */ export const setLink = function (ids, linkStr, tooltip) { - 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 (config.securityLevel !== 'loose') { vertices[id].link = sanitizeUrl(linkStr) // .replace(/javascript:.*/g, '')