Closed Bug 290336 Opened 20 years ago Closed 20 years ago

removeEventListener clobbering the wrong handler

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
major

Tracking

()

RESOLVED DUPLICATE of bug 174320

People

(Reporter: rleon, Assigned: bugzilla)

Details

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6) Gecko/20050317 Firefox/1.0.2 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6) Gecko/20050317 Firefox/1.0.2 If you remove an event handler, during the execution of the event during which it was scheduled to fire, but after it's already fired, then the next handler scheduled gets clobbered by removeEventListener. This is a simplified example, but when doing cross window scripting, there are valid reasons you want to do this, else on window will hold references to dom objects that no longer exist in another window when has navigated elsewhere. Reproducible: Always Steps to Reproduce: var firstEvent = function(){ alert('firstEvent'); } var secondEvent = function(){ alert('secondEvent'); } var thirdEvent = function(){ alert('thirdEvent'); } var unloadfirstEvent = function(){ alert('unhook firstEvent'); window.removeEventListener("unload", firstEvent, false); } //should fire window.addEventListener("unload", firstEvent, false); //should fire window.addEventListener("unload", unloadfirstEvent, false); //should fire but doesn't, line above killed it window.addEventListener("unload", secondEvent, false); //should fire window.addEventListener("unload", thirdEvent, false); Actual Results: removeEventListener kills the wrong handler, and the secondEvent doesn't fire Expected Results: the secondEvent should fire, it was never removed. IE handles this perfectly, about the only thing I've seen yet that it does better than firefox. This bug also happens in mozilla. Seems to be a bug in the Gecko DOM.
Severity: normal → major
*** This bug has been marked as a duplicate of 174320 ***
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.