This commit is contained in:
Mirco Wittrien 2019-11-10 17:29:00 +01:00
parent b3cfe31f28
commit 58767c42d0
2 changed files with 10 additions and 6 deletions

View File

@ -966,7 +966,8 @@ var BDFDB = {
BDFDB.ModuleUtils.patch = function (plugin, module, modulefunctions, patchfunctions) {
if (!plugin || !module || !modulefunctions || !Object.keys(patchfunctions).some(type => WebModulesData.Patchtypes.includes(type))) return null;
const pluginid = (typeof plugin === "string" ? plugin : plugin.name).toLowerCase();
const pluginname = typeof plugin === "string" ? plugin : plugin.name;
const pluginid = pluginname.toLowerCase();
if (!module.BDFDBpatch) module.BDFDBpatch = {};
modulefunctions = BDFDB.ArrayUtils.is(modulefunctions) ? modulefunctions : Array.of(modulefunctions);
for (let modulefunction of modulefunctions) {
@ -986,15 +987,15 @@ var BDFDB = {
};
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded && module.BDFDBpatch[modulefunction]) {
if (!BDFDB.ObjectUtils.isEmpty(module.BDFDBpatch[modulefunction].before)) for (let id in BDFDB.ObjectUtils.sort(module.BDFDBpatch[modulefunction].before)) {
BDFDB.TimeUtils.suppress(module.BDFDBpatch[modulefunction].before[id], `"before" callback of ${modulefunction} in ${module.constructor ? module.constructor.displayName || module.constructor.name : "module"}`, id)(data);
BDFDB.TimeUtils.suppress(module.BDFDBpatch[modulefunction].before[id], `"before" callback of ${modulefunction} in ${module.constructor ? module.constructor.displayName || module.constructor.name : "module"}`, module.BDFDBpatch[modulefunction].before[id].pluginname)(data);
}
if (BDFDB.ObjectUtils.isEmpty(module.BDFDBpatch[modulefunction].instead)) BDFDB.TimeUtils.suppress(data.callOriginalMethod, `originalMethod of ${modulefunction} in ${module.constructor ? module.constructor.displayName || module.constructor.name : "module"}`)();
else for (let id in BDFDB.ObjectUtils.sort(module.BDFDBpatch[modulefunction].instead)) {
let tempreturn = BDFDB.TimeUtils.suppress(module.BDFDBpatch[modulefunction].instead[id], `"instead" callback of ${modulefunction} in ${module.constructor ? module.constructor.displayName || module.constructor.name : "module"}`, id)(data);
let tempreturn = BDFDB.TimeUtils.suppress(module.BDFDBpatch[modulefunction].instead[id], `"instead" callback of ${modulefunction} in ${module.constructor ? module.constructor.displayName || module.constructor.name : "module"}`, module.BDFDBpatch[modulefunction].instead[id].pluginname)(data);
if (tempreturn !== undefined) data.returnValue = tempreturn;
}
if (!BDFDB.ObjectUtils.isEmpty(module.BDFDBpatch[modulefunction].after)) for (let id in BDFDB.ObjectUtils.sort(module.BDFDBpatch[modulefunction].after)) {
let tempreturn = BDFDB.TimeUtils.suppress(module.BDFDBpatch[modulefunction].after[id], `"after" callback of ${modulefunction} in ${module.constructor ? module.constructor.displayName || module.constructor.name : "module"}`, id)(data);
let tempreturn = BDFDB.TimeUtils.suppress(module.BDFDBpatch[modulefunction].after[id], `"after" callback of ${modulefunction} in ${module.constructor ? module.constructor.displayName || module.constructor.name : "module"}`, module.BDFDBpatch[modulefunction].after[id].pluginname)(data);
if (tempreturn !== undefined) data.returnValue = tempreturn;
}
}
@ -1002,7 +1003,10 @@ var BDFDB = {
return modulefunction == "render" && data.returnValue === undefined ? null : data.returnValue;
};
}
for (let type of WebModulesData.Patchtypes) if (typeof patchfunctions[type] == "function") module.BDFDBpatch[modulefunction][type][pluginid] = patchfunctions[type];
for (let type of WebModulesData.Patchtypes) if (typeof patchfunctions[type] == "function") {
module.BDFDBpatch[modulefunction][type][pluginid] = patchfunctions[type];
module.BDFDBpatch[modulefunction][type][pluginid].pluginname = pluginname;
}
}
let cancel = _ => {BDFDB.ModuleUtils.unpatch(plugin, module, modulefunctions);};
if (plugin && typeof plugin == "object") {

File diff suppressed because one or more lines are too long