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

feat: add Blockly.Extensions.isRegistered function #5500

Merged
merged 2 commits into from
Oct 7, 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
12 changes: 11 additions & 1 deletion core/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,24 @@ Blockly.Extensions.registerMutator = function(name, mixinObj, opt_helperFn,
* @param {string} name The name of the extension to unregister.
*/
Blockly.Extensions.unregister = function(name) {
if (Blockly.Extensions.ALL_[name]) {
if (Blockly.Extensions.isRegistered(name)) {
delete Blockly.Extensions.ALL_[name];
} else {
console.warn('No extension mapping for name "' + name +
'" found to unregister');
}
};

/**
* Returns whether an extension is registered with the given name.
* @param {string} name The name of the extension to check for.
* @return {boolean} True if the extension is registered. False if it is
* not registered.
*/
Blockly.Extensions.isRegistered = function(name) {
return !!Blockly.Extensions.ALL_[name];
};

/**
* Applies an extension method to a block. This should only be called during
* block construction.
Expand Down