mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
Throw if extension tries to build a dynamic menu
Dynamic menus are not yet supported for extension menus, though they are part of the extension spec. This change provides more thorough feedback if an extension tries to register an unsupported dynamic menu.
This commit is contained in:
parent
2f9796c163
commit
309f02542f
1 changed files with 4 additions and 1 deletions
|
@ -441,7 +441,7 @@ class Runtime extends EventEmitter {
|
|||
/**
|
||||
* Build the scratch-blocks JSON for a menu. Note that scratch-blocks treats menus as a special kind of block.
|
||||
* @param {string} menuName - the name of the menu
|
||||
* @param {array|string} menuItems - the list of menu items, or the name of an extension method to collect them.
|
||||
* @param {array} menuItems - the list of items for this menu
|
||||
* @param {CategoryInfo} categoryInfo - the category for this block
|
||||
* @returns {object} - a JSON-esque object ready for scratch-blocks' consumption
|
||||
* @private
|
||||
|
@ -450,6 +450,9 @@ class Runtime extends EventEmitter {
|
|||
const menuId = this._makeExtensionMenuId(menuName, categoryInfo.id);
|
||||
|
||||
/** @TODO: support dynamic menus when 'menuItems' is a method name string (see extension spec) */
|
||||
if (typeof menuItems === 'string') {
|
||||
throw new Error(`Dynamic extension menus are not yet supported. Menu name: ${menuName}`);
|
||||
}
|
||||
const options = menuItems.map(item => {
|
||||
switch (typeof item) {
|
||||
case 'string':
|
||||
|
|
Loading…
Reference in a new issue