aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/search.js
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2020-03-14 02:51:39 +0200
committersiikamiika <siikamiika@users.noreply.github.com>2020-03-21 22:13:07 +0200
commit46c6ad98f33ea1536452beb7e41f78f9a1895997 (patch)
tree80580ce3f32ae84ed146cc8cf43edac3bf4d2adc /ext/bg/js/search.js
parent962c2a381f3dace4d97fd0625504ec841e378354 (diff)
use dependency injection in QueryParser
Also fix an issue with settings update triggering a lookup on unprepared QueryParser.
Diffstat (limited to 'ext/bg/js/search.js')
-rw-r--r--ext/bg/js/search.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js
index 8b8ee55e..9250fdde 100644
--- a/ext/bg/js/search.js
+++ b/ext/bg/js/search.js
@@ -29,12 +29,18 @@ class DisplaySearch extends Display {
constructor() {
super(document.querySelector('#spinner'), document.querySelector('#content'));
+ this._isPrepared = false;
+
this.optionsContext = {
depth: 0,
url: window.location.href
};
- this.queryParser = new QueryParser(this);
+ this.queryParser = new QueryParser({
+ getOptionsContext: this.getOptionsContext.bind(this),
+ setContent: this.setContent.bind(this),
+ setSpinnerVisible: this.setSpinnerVisible.bind(this)
+ });
this.search = document.querySelector('#search');
this.query = document.querySelector('#query');
@@ -112,6 +118,8 @@ class DisplaySearch extends Display {
this.clipboardMonitor.on('change', this.onExternalSearchUpdate.bind(this));
this.updateSearchButton();
+
+ this._isPrepared = true;
} catch (e) {
this.onError(e);
}
@@ -278,6 +286,7 @@ class DisplaySearch extends Display {
async updateOptions() {
await super.updateOptions();
this.queryParser.setOptions(this.options);
+ if (!this._isPrepared) { return; }
const query = this.query.value;
if (query) {
this.setQuery(query);