Переглянути джерело

Merge pull request #309 from richardwillars/addplugin

Checks for plugin type and plugin id rather than name
Renée Kooi 7 роки тому
батько
коміт
1e07cf1139
2 змінених файлів з 6 додано та 7 видалено
  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
     // Instantiate
     const plugin = new Plugin(this, opts)
     const plugin = new Plugin(this, opts)
-    const pluginName = plugin.id
+    const pluginId = plugin.id
     this.plugins[plugin.type] = this.plugins[plugin.type] || []
     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) {
     if (!plugin.type) {
       throw new Error('Your plugin must have a type')
       throw new Error('Your plugin must have a type')
     }
     }
 
 
-    let existsPluginAlready = this.getPlugin(pluginName)
+    let existsPluginAlready = this.getPlugin(pluginId)
     if (existsPluginAlready) {
     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.
         Uppy is currently limited to running one of every plugin.
         Share your use case with us over at
         Share your use case with us over at
         https://github.com/transloadit/uppy/issues/
         https://github.com/transloadit/uppy/issues/

+ 0 - 1
src/plugins/Plugin.js

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