From 6a6d7ba84e778d1e5917f905748fe752a8712016 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Fri, 19 Feb 2021 18:39:36 -0500 Subject: Fix wanakana.unbind throwing an error (#1422) --- ext/js/display/search-display-controller.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ext/js/display/search-display-controller.js b/ext/js/display/search-display-controller.js index d1a4593f..c8025d62 100644 --- a/ext/js/display/search-display-controller.js +++ b/ext/js/display/search-display-controller.js @@ -33,6 +33,7 @@ class SearchDisplayController { this._queryInputEvents = new EventListenerCollection(); this._queryInputEventsSetup = false; this._wanakanaEnabled = false; + this._wanakanaBound = false; this._introVisible = true; this._introAnimationTimer = null; this._clipboardMonitorEnabled = false; @@ -223,9 +224,15 @@ class SearchDisplayController { this._wanakanaEnabled = enabled; if (enabled) { - wanakana.bind(input); + if (!this._wanakanaBound) { + wanakana.bind(input); + this._wanakanaBound = true; + } } else { - wanakana.unbind(input); + if (this._wanakanaBound) { + wanakana.unbind(input); + this._wanakanaBound = true; + } } this._queryInputEvents.addEventListener(input, 'input', this._onSearchInput.bind(this), false); -- cgit v1.2.3