This commit is contained in:
Matthieu MOREL
2020-12-06 10:45:13 +01:00
parent 027342bba0
commit 7126d215b0

View File

@@ -257,27 +257,24 @@ const setClickFun = function(id, functionName, functionArgs) {
return; return;
} }
let argList = []; let argList = [];
if (typeof functionArgs === 'string') { if (typeof functionArgs === 'string') {
/* Splits functionArgs by ',', ignoring all ',' in double quoted strings */ /* Splits functionArgs by ',', ignoring all ',' in double quoted strings */
argList = functionArgs.split(/,(?=(?:(?:[^"]*"){2})*[^"]*$)/); argList = functionArgs.split(/,(?=(?:(?:[^"]*"){2})*[^"]*$)/);
for (let i = 0; i < argList.length; i++) { for (let i = 0; i < argList.length; i++) {
let item = argList[i].trim(); let item = argList[i].trim();
/* Removes all double quotes at the start and end of an argument */ /* Removes all double quotes at the start and end of an argument */
/* This preserves all starting and ending whitespace inside */ /* This preserves all starting and ending whitespace inside */
if (item.charAt(0) === '"' && item.charAt(item.length - 1) === '"') { if (item.charAt(0) === '"' && item.charAt(item.length - 1) === '"') {
item = item.substr(1, item.length - 2); item = item.substr(1, item.length - 2);
}
argList[i] = item;
} }
argList[i] = item;
} }
}
/* if no arguments passed into callback, default to passing in id */ /* if no arguments passed into callback, default to passing in id */
if (argList.length === 0) { if (argList.length === 0) {
argList.push(id); argList.push(id);
} }
if (typeof vertices[id] !== 'undefined') { if (typeof vertices[id] !== 'undefined') {
vertices[id].haveCallback = true; vertices[id].haveCallback = true;
@@ -724,6 +721,7 @@ export default {
addClass, addClass,
setDirection, setDirection,
setClass, setClass,
setTooltip,
getTooltip, getTooltip,
setClickEvent, setClickEvent,
setLink, setLink,