Skip to content

Commit

Permalink
fixed a dictionary lookup glitch for custom block categories
Browse files Browse the repository at this point in the history
  • Loading branch information
jmoenig committed Oct 13, 2024
1 parent d9efec8 commit af4f4ee
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 3 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 3 additions & 4 deletions src/objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit af4f4ee

Please sign in to comment.