#922 Fix for click binding on nodes with ids starting with a number

This commit is contained in:
knsv 2019-09-03 11:31:47 -07:00
parent f4bafacc62
commit 21aa8c5f15
2 changed files with 12 additions and 2 deletions

View File

@ -13,6 +13,12 @@
click Function clickByFlow "Add a div"
click URL "https://mermaidjs.github.io/" "Visit <strong>mermaid docs</strong>"
</div>
<div id="FirstLine" class="mermaid">
graph TB
1Function-->2URL
click 1Function clickByFlow "Add a div"
click 2URL "https://mermaidjs.github.io/" "Visit <strong>mermaid docs</strong>"
</div>
<div class="mermaid">
gantt

View File

@ -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, '')