Skip to content
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

Handle overriding components in ComponentManager #4856

Merged
merged 4 commits into from
Jun 8, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Handle overriding plugins in PluginManager
kozbial committed May 27, 2021
commit e371568a647c71130c73ebb200c53dc01ced875a
11 changes: 10 additions & 1 deletion core/plugin_manager.js
Original file line number Diff line number Diff line change
@@ -48,9 +48,18 @@ Blockly.PluginManager.PluginDatum;
/**
* Adds a plugin.
* @param {!Blockly.PluginManager.PluginDatum} pluginDataObject The plugin.
* @param {boolean=} opt_allowOverrides True to prevent an error when overriding
* an already registered item.
* @template T
*/
Blockly.PluginManager.prototype.addPlugin = function(pluginDataObject) {
Blockly.PluginManager.prototype.addPlugin = function(
pluginDataObject, opt_allowOverrides) {
// Don't throw an error if opt_allowOverrides is true.
if (!opt_allowOverrides && this.pluginData_[pluginDataObject.id]) {
throw Error(
'Plugin "' + pluginDataObject.id + '" with types "' +
this.pluginData_[pluginDataObject.id].types + '" already added.');
}
this.pluginData_[pluginDataObject.id] = pluginDataObject;
for (var i = 0, type; (type = pluginDataObject.types[i]); i++) {
var typeKey = String(type).toLowerCase();