Make sure there are no parameters before trying nice check for function name

This commit is contained in:
nathangray 2020-04-24 11:23:03 -06:00
parent 878dc659b1
commit 5a1f642ce2

View File

@ -125,25 +125,24 @@
// Check to see if it's referring to an existing function with no arguments specified. // Check to see if it's referring to an existing function with no arguments specified.
// If so, bind context & use it directly // If so, bind context & use it directly
var parts = _code.split("."); if(_code.indexOf("(") === -1)
var existing_func = parts.pop();
var parent = _widget.egw().window;
for(var i=0; i < parts.length; ++i)
{ {
if (typeof parent[parts[i]] !== "undefined") var parts = _code.split(".");
{ var existing_func = parts.pop();
parent = parent[parts[i]]; var parent = _widget.egw().window;
for (var i = 0; i < parts.length; ++i) {
if (typeof parent[parts[i]] !== "undefined") {
parent = parent[parts[i]];
}
// Nope
else {
break;
}
} }
// Nope if (typeof parent[existing_func] === "function") {
else return parent[existing_func].bind(context);
{
break;
} }
} }
if (typeof parent[existing_func] === "function")
{
return parent[existing_func].bind(context);
}
// Generate the function itself, if it fails, log the error message and // Generate the function itself, if it fails, log the error message and
// return a function which always returns false // return a function which always returns false