-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't throw when re-registering a plugin #4140
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import evented from './mixins/evented'; | |
import stateful from './mixins/stateful'; | ||
import * as Events from './utils/events'; | ||
import * as Fn from './utils/fn'; | ||
import log from './utils/log'; | ||
import Player from './player'; | ||
|
||
/** | ||
|
@@ -305,8 +306,10 @@ class Plugin { | |
throw new Error(`Illegal plugin name, "${name}", must be a string, was ${typeof name}.`); | ||
} | ||
|
||
if (pluginExists(name) || Player.prototype.hasOwnProperty(name)) { | ||
throw new Error(`Illegal plugin name, "${name}", already exists.`); | ||
if (pluginExists(name)) { | ||
log.warn(`A plugin named "${name}" already exists. You may want to avoid re-registering plugins!`); | ||
} else if (Player.prototype.hasOwnProperty(name)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This sounds like a reasonable compromise. |
||
throw new Error(`Illegal plugin name, "${name}", cannot share a name with an existing player method!`); | ||
} | ||
|
||
if (typeof plugin !== 'function') { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@misteroneill when you get the chance, can you make another PR that silences this warning in the plugin tests?