diff --git a/HISTORY.md b/HISTORY.md index 660d6badb..7e5bd4296 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,6 +2,9 @@ ## in development: +### 2024-09-13 +* objects, gui: fixed a dictionary lookup glitch for custom block categories + ## 10.1.2: * **Notable Fixes:** * only bind rings that replace list items to the list as environment if they are referred to by a non-numerical index (OOP 2.0) diff --git a/src/gui.js b/src/gui.js index 0d7949a7a..6ce265a67 100644 --- a/src/gui.js +++ b/src/gui.js @@ -1656,7 +1656,7 @@ IDE_Morph.prototype.createCategories = function () { var dict = myself.currentSprite.emptyCategories(); dict.variables = dict.variables || dict.lists || dict.other; this.buttons.forEach(cat => { - if (dict[cat.category]) { + if (Object.hasOwn(dict, cat.category) && (dict[cat.category])) { cat.enable(); } else { cat.disable(); diff --git a/src/objects.js b/src/objects.js index 031fa0648..aff9c0a28 100644 --- a/src/objects.js +++ b/src/objects.js @@ -184,9 +184,8 @@ SpriteMorph.prototype.allCategories = function () { }; SpriteMorph.prototype.blockColorFor = function (category) { - return this.blockColor[category] || - this.customCategories.get(category) || - this.blockColor.other; + return Object.hasOwn(this.blockColor, category) ? this.blockColor[category] + : this.customCategories.get(category) || this.blockColor.other; }; SpriteMorph.prototype.paletteColor = new Color(55, 55, 55); @@ -4158,7 +4157,7 @@ SpriteMorph.prototype.getPrimitiveTemplates = function (category) { }; SpriteMorph.prototype.palette = function (category) { - if (!this.paletteCache[category]) { + if (!Object.hasOwn(this.paletteCache, category)) { this.paletteCache[category] = this.freshPalette(category); } return this.paletteCache[category];