mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-24 10:47:44 +00:00
Fix the plugin naming system so it works when bundle is minified
This commit is contained in:
parent
169313bd50
commit
dc2bb9636d
4 changed files with 9 additions and 9 deletions
|
|
@ -240,7 +240,7 @@ export default class Core {
|
|||
use (Plugin, opts) {
|
||||
// Instantiate
|
||||
const plugin = new Plugin(this, opts)
|
||||
const pluginName = Utils.getFnName(plugin.constructor)
|
||||
const pluginName = plugin.id
|
||||
this.plugins[plugin.type] = this.plugins[plugin.type] || []
|
||||
|
||||
if (!pluginName) {
|
||||
|
|
@ -254,7 +254,7 @@ export default class Core {
|
|||
let existsPluginAlready = this.getPlugin(pluginName)
|
||||
if (existsPluginAlready) {
|
||||
let msg = `Already found a plugin named '${existsPluginAlready.name}'.
|
||||
Tried to use: '${plugin.constructor.name}'.
|
||||
Tried to use: '${pluginName}'.
|
||||
Uppy is currently limited to running one of every plugin.
|
||||
Share your use case with us over at
|
||||
https://github.com/transloadit/uppy/issues/
|
||||
|
|
@ -275,7 +275,7 @@ export default class Core {
|
|||
getPlugin (name) {
|
||||
let foundPlugin = false
|
||||
this.iteratePlugins((plugin) => {
|
||||
const pluginName = Utils.getFnName(plugin.constructor)
|
||||
const pluginName = plugin.id
|
||||
if (pluginName === name) {
|
||||
foundPlugin = plugin
|
||||
return false
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ export default class Dummy extends Plugin {
|
|||
return yo`
|
||||
<div class="wow-this-works">
|
||||
<input type="text" value="hello">
|
||||
I am a dummy plugin, look at me, I was rendered in a modal! That’s crazy, I know.
|
||||
${this.strange}
|
||||
${bla}
|
||||
</div>
|
||||
|
|
@ -40,6 +39,6 @@ export default class Dummy extends Plugin {
|
|||
|
||||
install () {
|
||||
this.el = this.render()
|
||||
this.target = this.getTarget(this.opts.target, this, this.el, this.render.bind(this))
|
||||
this.target = this.getTarget(this.opts.target, this, this.el, this.render)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ export default class Modal extends Plugin {
|
|||
|
||||
addTarget (callerPlugin, render) {
|
||||
const callerPluginId = callerPlugin.constructor.name
|
||||
const callerPluginName = callerPlugin.name || callerPluginId
|
||||
const callerPluginName = callerPlugin.title || callerPluginId
|
||||
const callerPluginIcon = callerPlugin.icon || this.opts.defaultTabIcon
|
||||
const callerPluginType = callerPlugin.type
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import yo from 'yo-yo'
|
||||
import Utils from '../core/Utils'
|
||||
|
||||
/**
|
||||
* Boilerplate that all Plugins share - and should not be used
|
||||
|
|
@ -37,7 +36,7 @@ export default class Plugin {
|
|||
*
|
||||
*/
|
||||
getTarget (target, caller, el, render) {
|
||||
const callerPluginName = Utils.getFnName(caller.constructor)
|
||||
const callerPluginName = caller.id
|
||||
|
||||
if (typeof target === 'string') {
|
||||
this.core.log(`Installing ${callerPluginName} to ${target}`)
|
||||
|
|
@ -50,7 +49,9 @@ export default class Plugin {
|
|||
|
||||
return target
|
||||
} else {
|
||||
const targetPluginName = Utils.getFnName(target)
|
||||
// TODO: is this the way to roll just to get the plugin name?
|
||||
const Target = target
|
||||
const targetPluginName = new Target().id
|
||||
this.core.log(`Installing ${callerPluginName} to ${targetPluginName}`)
|
||||
let targetPlugin = this.core.getPlugin(targetPluginName)
|
||||
let selectorTarget = targetPlugin.addTarget(caller, render)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue