Fix wanakana.unbind throwing an error (#1422)

This commit is contained in:
toasted-nutbread 2021-02-19 18:39:36 -05:00 committed by GitHub
parent 19d0d5b512
commit 6a6d7ba84e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,6 +33,7 @@ class SearchDisplayController {
this._queryInputEvents = new EventListenerCollection(); this._queryInputEvents = new EventListenerCollection();
this._queryInputEventsSetup = false; this._queryInputEventsSetup = false;
this._wanakanaEnabled = false; this._wanakanaEnabled = false;
this._wanakanaBound = false;
this._introVisible = true; this._introVisible = true;
this._introAnimationTimer = null; this._introAnimationTimer = null;
this._clipboardMonitorEnabled = false; this._clipboardMonitorEnabled = false;
@ -223,9 +224,15 @@ class SearchDisplayController {
this._wanakanaEnabled = enabled; this._wanakanaEnabled = enabled;
if (enabled) { if (enabled) {
if (!this._wanakanaBound) {
wanakana.bind(input); wanakana.bind(input);
this._wanakanaBound = true;
}
} else { } else {
if (this._wanakanaBound) {
wanakana.unbind(input); wanakana.unbind(input);
this._wanakanaBound = true;
}
} }
this._queryInputEvents.addEventListener(input, 'input', this._onSearchInput.bind(this), false); this._queryInputEvents.addEventListener(input, 'input', this._onSearchInput.bind(this), false);