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 all commits
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
14 changes: 13 additions & 1 deletion core/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ exports.registerMutator = registerMutator;
* @alias Blockly.Extensions.unregister
*/
const unregister = function(name) {
if (allExtensions[name]) {
if (isRegistered(name)) {
delete allExtensions[name];
} else {
console.warn(
Expand All @@ -136,6 +136,18 @@ const unregister = function(name) {
};
exports.unregister = 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.
* @alias Blockly.Extensions.isRegistered
*/
const isRegistered = function(name) {
return !!allExtensions[name];
};
exports.isRegistered = isRegistered;

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