diff --git a/content_scripts/dictionary-plus.js b/content_scripts/dictionary-plus.js index da33fb0..4cabd55 100644 --- a/content_scripts/dictionary-plus.js +++ b/content_scripts/dictionary-plus.js @@ -543,7 +543,10 @@ function saveWord(key) { function updatePopUp(key, data) { - const popupNode = OPENED_POPUPS[key].node; + const popupNode = OPENED_POPUPS[key]?.node; + + // If user clicks out before definition is retrieved, `OPEN_POPUPS[key]` will not exist + if (popupNode === undefined) return; const popup = popupNode.shadowRoot; @@ -667,4 +670,4 @@ function onStorageChange(changes, area) { SETTINGS = settings.newValue; } -browser.storage.onChanged.addListener(onStorageChange); \ No newline at end of file +browser.storage.onChanged.addListener(onStorageChange);