From a5b208fb895d46793223910451d177dc53d9463a Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 12 Oct 2019 14:41:24 -0400 Subject: Check if objects are properly initialized before showing content --- ext/fg/js/popup.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'ext/fg/js') diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js index 396a5be9..a9fde7b6 100644 --- a/ext/fg/js/popup.js +++ b/ext/fg/js/popup.js @@ -79,6 +79,10 @@ class Popup { }); } + isInitialized() { + return this.options !== null; + } + async setOptions(options) { this.options = options; } @@ -212,6 +216,7 @@ class Popup { } async showOrphaned(elementRect, writingMode, options) { + if (!this.isInitialized()) { return; } await this.show(elementRect, writingMode, options); this.invokeApi('orphaned'); } @@ -275,11 +280,13 @@ class Popup { } async termsShow(elementRect, writingMode, definitions, options, context) { + if (!this.isInitialized()) { return; } await this.show(elementRect, writingMode, options); this.invokeApi('termsShow', {definitions, options, context}); } async kanjiShow(elementRect, writingMode, definitions, options, context) { + if (!this.isInitialized()) { return; } await this.show(elementRect, writingMode, options); this.invokeApi('kanjiShow', {definitions, options, context}); } -- cgit v1.2.3