From d39f885a3393d4297a5911103e07bb3d724c00bd Mon Sep 17 00:00:00 2001 From: Ben Sgroi Date: Mon, 24 Sep 2018 17:10:12 -0400 Subject: [PATCH] Fixed permanent event listeners When calling `removeEventListener`, the `useCapture` param must match the value that the listener was added with, otherwise the handler is never removed. This issue results in the closure context staying on the heap permanently, which causes memory leaks. --- angular-click-outside.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angular-click-outside.js b/angular-click-outside.js index 8f73dc2..a3a283a 100644 --- a/angular-click-outside.js +++ b/angular-click-outside.js @@ -25,7 +25,7 @@ function twClickOutside ($window, $parse) { $window.addEventListener('click', handler, true); scope.$on('$destroy', function(e) { - $window.removeEventListener('click', handler); + $window.removeEventListener('click', handler, true); }); } };