1
0
Fork 0

fix(core): Don't load plugins twice

This commit is contained in:
Joost De Cock 2022-09-01 17:43:35 +02:00
parent 07528ecf95
commit c79aea43b9

View file

@ -47,6 +47,9 @@ export function Pattern(config = { options: {} }) {
warning: [],
}
// Keep track of loaded plugins
this.plugins = {}
// Raise methods - Make events and settings avialable in them
const events = this.events
const settings = this.settings
@ -536,6 +539,9 @@ Pattern.prototype.on = function (hook, method, data) {
}
Pattern.prototype.use = function (plugin, data) {
// Don't load plugins more than once
if (this.plugins?.[plugin.name]) return this
this.plugins[plugin.name] = plugin
// Conditional plugin?
if (plugin.plugin && plugin.condition) return this.useIf(plugin, data)
// Regular plugin