Przeglądaj źródła

Merge pull request #309 from richardwillars/addplugin

Checks for plugin type and plugin id rather than name
Renée Kooi 7 lat temu
rodzic
commit
1e07cf1139
2 zmienionych plików z 6 dodań i 7 usunięć
  1. 6 6
      src/core/Core.js
  2. 0 1
      src/plugins/Plugin.js

+ 6 - 6
src/core/Core.js

@@ -612,21 +612,21 @@ class Uppy {
 
     // Instantiate
     const plugin = new Plugin(this, opts)
-    const pluginName = plugin.id
+    const pluginId = plugin.id
     this.plugins[plugin.type] = this.plugins[plugin.type] || []
 
-    if (!pluginName) {
-      throw new Error('Your plugin must have a name')
+    if (!pluginId) {
+      throw new Error('Your plugin must have an id')
     }
 
     if (!plugin.type) {
       throw new Error('Your plugin must have a type')
     }
 
-    let existsPluginAlready = this.getPlugin(pluginName)
+    let existsPluginAlready = this.getPlugin(pluginId)
     if (existsPluginAlready) {
-      let msg = `Already found a plugin named '${existsPluginAlready.name}'.
-        Tried to use: '${pluginName}'.
+      let msg = `Already found a plugin named '${existsPluginAlready.id}'.
+        Tried to use: '${pluginId}'.
         Uppy is currently limited to running one of every plugin.
         Share your use case with us over at
         https://github.com/transloadit/uppy/issues/

+ 0 - 1
src/plugins/Plugin.js

@@ -17,7 +17,6 @@ module.exports = class Plugin {
   constructor (core, opts) {
     this.core = core
     this.opts = opts || {}
-    this.type = 'none'
 
     // clear everything inside the target selector
     this.opts.replaceTargetContent === this.opts.replaceTargetContent || true