[gnome-bootstrap-theme] fix: only execute code if search element exists
- From: Guillaume Bernard <gbernard src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-bootstrap-theme] fix: only execute code if search element exists
- Date: Sun, 25 Sep 2022 13:25:04 +0000 (UTC)
commit c73fed45a4277da789b0dbf047e54b7f44f7b8c2
Author: Guillaume Bernard <associations guillaume-bernard fr>
Date: Sun Sep 25 15:14:24 2022 +0200
fix: only execute code if search element exists
src/js/navbar-search-form.js | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/src/js/navbar-search-form.js b/src/js/navbar-search-form.js
index 2aab4e2..18a6619 100644
--- a/src/js/navbar-search-form.js
+++ b/src/js/navbar-search-form.js
@@ -1,7 +1,10 @@
const searchbar = document.getElementById('.js-search');
-document.getElementById('.js-search-toggle').onclick = function () {
- searchbar.parent.closest('div').classList.toggle('is-visible');
- setTimeout(function () {
- searchbar.focus()
- }, 350)
-};
+const js_search_toggle = document.getElementById('.js-search-toggle')
+if (js_search_toggle) {
+ js_search_toggle.onclick = function () {
+ searchbar.parent.closest('div').classList.toggle('is-visible');
+ setTimeout(function () {
+ searchbar.focus()
+ }, 350)
+ };
+}
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]