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

Commit

Permalink
fix(browser/utils): calling removeEventListener twice with the same a…
Browse files Browse the repository at this point in the history
…rgs should not cause errors

Closes #283

Closes #284
  • Loading branch information
sjelin authored and mhevery committed Mar 21, 2016
1 parent 4a4d4f6 commit 1787339
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
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);
});
});

});

0 comments on commit 1787339

Please sign in to comment.