Skip to content

Commit

Permalink
Add brackets where required due to JS precedence
Browse files Browse the repository at this point in the history
Fixes #25
  • Loading branch information
aiden2480 committed Jun 27, 2022
1 parent 86bc5a5 commit 52322a7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion background.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ async function createDefaultConfig() {

/* Context menus */
chrome.storage.onChanged.addListener(async (changes, namespace) => {
if (!"customsets" in changes) return;
if (!("customsets" in changes)) return;

This comment has been minimized.

Copy link
@aiden2480

aiden2480 Jun 27, 2022

Author Owner

This error was a result of a misunderstanding of the order of precedence in JavaScript.

// I thought the following would evaluate as inverse of `"customsets" in changes`
!"customsets" in changes

// But instead if evaluates as the following, giving the not operator
// precedence over the in keyword -> !"customsets" == false
false in changes

This would always evaluate to false as there was a 0% chance of the boolean false being a member of the changes object.


chrome.contextMenus.removeAll(() => {
generateContextMenus();
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "KanjiThing",
"description": "Learn kanji stroke order from the browser",
"version": "2.0.2",
"version": "2.1.0",
"manifest_version": 3,
"permissions": ["storage", "contextMenus"],
"options_page": "settings.html",
Expand Down

0 comments on commit 52322a7

Please sign in to comment.