DEV: do not append/prepend if callback returns nothing (#9778)

This commit is contained in:
Joffrey JAFFEUX
2020-05-14 14:38:03 +02:00
committed by GitHub
parent 3ed6a0e904
commit 42e5a5bb39
2 changed files with 22 additions and 10 deletions

View File

@@ -32,10 +32,16 @@ function onChange(pluginApiIdentifiers, mutationFunction) {
export function applyContentPluginApiCallbacks(content, component) {
makeArray(component.pluginApiIdentifiers).forEach(key => {
(_prependContentCallbacks[key] || []).forEach(c => {
content = makeArray(c(component, content)).concat(content);
const prependedContent = c(component, content);
if (prependedContent) {
content = makeArray(prependedContent).concat(content);
}
});
(_appendContentCallbacks[key] || []).forEach(c => {
content = content.concat(makeArray(c(component, content)));
const appendedContent = c(component, content);
if (appendedContent) {
content = content.concat(makeArray(appendedContent));
}
});
});