diff --git a/lib/browser/utils.ts b/lib/browser/utils.ts index 6e12b9eaf..5d7ef7375 100644 --- a/lib/browser/utils.ts +++ b/lib/browser/utils.ts @@ -195,7 +195,7 @@ function zoneAwareRemoveEventListener(self: any, args: any[]) { // - When `addEventListener` is called on the global context in strict mode, `this` is undefined // see https://github.com/angular/zone.js/issues/190 var target = self || _global; - var eventTask = findExistingRegisteredTask(target, handler, eventName, useCapturing, false); + var eventTask = findExistingRegisteredTask(target, handler, eventName, useCapturing, true); if (eventTask) { eventTask.zone.cancelTask(eventTask); } else { diff --git a/test/browser/element.spec.ts b/test/browser/element.spec.ts index c128757bd..b8e2b371d 100644 --- a/test/browser/element.spec.ts +++ b/test/browser/element.spec.ts @@ -257,6 +257,13 @@ describe('element', function () { button.click(); expect(log).toEqual(''); }); + + it('should be able to deregister the same event twice', function() { + var listener = (event) => {}; + document.body.addEventListener('click', listener, false); + document.body.removeEventListener('click', listener, false); + document.body.removeEventListener('click', listener, false); + }); }); });