Skip to content

Commit

Permalink
if el is a NodeList remove the eventListener from the Nodes themselves (
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake Champion authored Mar 21, 2020
1 parent 219cb9f commit 32c8207
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/js/oCrossword.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
};

Expand Down

0 comments on commit 32c8207

Please sign in to comment.