Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

fix(browser/utils): calling removeEventListener twice with the same a… #284

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/browser/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions test/browser/element.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

});