From 32c82076ab615617fa09dcb5d0bd6ad126e3c12f Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Sat, 21 Mar 2020 16:34:50 +0000 Subject: [PATCH] if el is a NodeList remove the eventListener from the Nodes themselves (#73) --- src/js/oCrossword.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/js/oCrossword.js b/src/js/oCrossword.js index 0cf881b..8531b95 100644 --- a/src/js/oCrossword.js +++ b/src/js/oCrossword.js @@ -1495,7 +1495,11 @@ OCrossword.prototype.addEventListener = function(el, type, callback) { OCrossword.prototype.removeAllEventListeners = function() { this.listeners.forEach(function remove({el, type, callback}) { - el.removeEventListener(type, callback); + if (el instanceof NodeList) { + el.forEach(node => node.removeEventListener(type, callback)); + } else { + el.removeEventListener(type, callback); + } }); };