From 309f02542f6ac9cb78e1d83a0abaa104437a2feb Mon Sep 17 00:00:00 2001 From: Christopher Willis-Ford Date: Wed, 11 Oct 2017 11:41:03 -0700 Subject: [PATCH] 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. --- src/engine/runtime.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/engine/runtime.js b/src/engine/runtime.js index 17e58aab0..4cc2d3800 100644 --- a/src/engine/runtime.js +++ b/src/engine/runtime.js @@ -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':