From 62fe2ef600e340747e5bbec65cabcc24bc20596d Mon Sep 17 00:00:00 2001 From: Fabien Basmaison Date: Tue, 6 Apr 2021 11:37:23 +0200 Subject: [PATCH] [assets] Replace inline events with `addEventListener`; this breaks sliding menu. --- bookwyrm/static/js/bookwyrm.js | 10 +++++----- bookwyrm/static/js/localstorage.js | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bookwyrm/static/js/bookwyrm.js b/bookwyrm/static/js/bookwyrm.js index 0ba4b7c2..6be1d4fb 100644 --- a/bookwyrm/static/js/bookwyrm.js +++ b/bookwyrm/static/js/bookwyrm.js @@ -11,23 +11,23 @@ let BookWyrm = new class { initEventListeners() { // buttons that display or hide content document.querySelectorAll('[data-controls]') - .forEach(button => button.onclick = this.toggleAction.bind(this)); + .forEach(button => button.addEventListener('click', this.toggleAction.bind(this))); // javascript interactions (boost/fav) document.querySelectorAll('.interaction') - .forEach(button => button.onsubmit = this.interact.bind(this)); + .forEach(button => button.addEventListener('submit', this.interact.bind(this))); // handle aria settings on menus document.querySelectorAll('.pulldown-menu') - .forEach(button => button.onclick = this.toggleMenu.bind(this)); + .forEach(button => button.addEventListener('click', this.toggleMenu.bind(this))); // hidden submit button in a form document.querySelectorAll('.hidden-form input') - .forEach(button => button.onchange = this.revealForm.bind(this)); + .forEach(button => button.addEventListener('change', this.revealForm.bind(this))); // browser back behavior document.querySelectorAll('[data-back]') - .forEach(button => button.onclick = this.back); + .forEach(button => button.addEventListener('click', this.back)); } /** diff --git a/bookwyrm/static/js/localstorage.js b/bookwyrm/static/js/localstorage.js index 08b83162..17adf2bf 100644 --- a/bookwyrm/static/js/localstorage.js +++ b/bookwyrm/static/js/localstorage.js @@ -9,7 +9,7 @@ let LocalStorageTools = new class { // update localstorage document.querySelectorAll('.set-display') - .forEach(t => t.onclick = this.updateDisplay.bind(this)); + .forEach(t => t.addEventListener('click', this.updateDisplay.bind(this))); } // set javascript listeners