From dd17330cb86a9e01cbb5ad31ab72fd8a07fa82f0 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Sat, 19 Jun 2021 11:45:45 +0200 Subject: [PATCH] fixed search for dynamic extension menus --- HISTORY.md | 1 + snap.html | 2 +- src/byob.js | 25 ++++++++++++++----------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 43d290a6..0c70df97 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -9,6 +9,7 @@ ### 2021-06-19 * extensions: added color extension primitives +* byob: fixed search for dynamic extension menus ### 2021-06-18 * extensions: added text extension primitives diff --git a/snap.html b/snap.html index cf2860d9..cfb40785 100755 --- a/snap.html +++ b/snap.html @@ -14,7 +14,7 @@ - + diff --git a/src/byob.js b/src/byob.js index 18ef652b..ecfc4e73 100644 --- a/src/byob.js +++ b/src/byob.js @@ -106,7 +106,7 @@ WatcherMorph, XML_Serializer, SnapTranslator, SnapExtensions*/ // Global stuff //////////////////////////////////////////////////////// -modules.byob = '2021-June-18'; +modules.byob = '2021-June-19'; // Declarations @@ -380,16 +380,19 @@ CustomBlockDefinition.prototype.menuSearchWords = function () { var menu = this.dropDownMenuOf(slot); if (menu) { if (isString(menu)) { // special menu, translates its values - menu = InputSlotMorph.prototype[menu](true); - terms.push( - Object.values(menu).map(entry => { - if (isNil(entry)) {return ''; } - if (entry instanceof Array) { - return localize(entry[0]); - } - return entry.toString(); - }).join(' ') - ); + if (typeof InputSlotMorph.prototype[menu] === 'function') { + // catch typos in extension menus + menu = InputSlotMorph.prototype[menu](true); + terms.push( + Object.values(menu).map(entry => { + if (isNil(entry)) {return ''; } + if (entry instanceof Array) { + return localize(entry[0]); + } + return entry.toString(); + }).join(' ') + ); + } } else { // assume a dictionary, take its keys terms.push(Object.keys(menu).join(' ')); }