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.
// If so, bind context & use it directly
var parts = _code.split(".");
var existing_func = parts.pop();
var parent = _widget.egw().window;
for(var i=0; i < parts.length; ++i)
if(_code.indexOf("(") === -1)
{
if (typeof parent[parts[i]] !== "undefined")
{
parent = parent[parts[i]];
var parts = _code.split(".");
var existing_func = parts.pop();
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
else
{
break;
if (typeof parent[existing_func] === "function") {
return parent[existing_func].bind(context);
}
}
if (typeof parent[existing_func] === "function")
{
return parent[existing_func].bind(context);
}
// Generate the function itself, if it fails, log the error message and
// return a function which always returns false