From 9174abf855ddbc90e2b0167366e237106f6c9fef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9e=20Kooi?= Date: Mon, 4 Sep 2017 14:59:37 +0200 Subject: [PATCH] core: make `mount()`ing an unknown plugin a noop --- src/plugins/Plugin.js | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/plugins/Plugin.js b/src/plugins/Plugin.js index c86dbb17f..c1c5bcab8 100644 --- a/src/plugins/Plugin.js +++ b/src/plugins/Plugin.js @@ -73,24 +73,27 @@ module.exports = class Plugin { targetElement.appendChild(this.el) return targetElement - } else { - const Target = target - // Find the target plugin instance. - let targetPlugin - this.core.iteratePlugins((plugin) => { - if (plugin instanceof Target) { - targetPlugin = plugin - return false - } - }) - const targetPluginName = targetPlugin.id - - this.core.log(`Installing ${callerPluginName} to ${targetPluginName}`) - - const selectorTarget = targetPlugin.addTarget(plugin) - - return selectorTarget } + + const Target = target + // Find the target plugin instance. + let targetPlugin + this.core.iteratePlugins((plugin) => { + if (plugin instanceof Target) { + targetPlugin = plugin + return false + } + }) + + if (targetPlugin) { + const targetPluginName = targetPlugin.id + this.core.log(`Installing ${callerPluginName} to ${targetPluginName}`) + return targetPlugin.addTarget(plugin) + } + + this.core.log(`Not installing ${callerPluginName}`) + + return null } unmount () {