Closed Bug 906608 Opened 11 years ago Closed 9 years ago

Modify (remove) candidate event listeners is wrong

Categories

(Core :: DOM: Events, defect)

26 Branch
x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: crimsteam, Unassigned)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0 (Beta/Release) Build ID: 20130814063812 Steps to reproduce: I dont know what behaviour should be 100% properly, but whe have this from Document Object Model (DOM) Level 3 Events Specification candidate event listeners The list of all event listeners that have been registered on the target object in their order of registration. This list is captured or "frozen" before event listeners on the target object are dispatched, and released or "un-frozen" after this set of candidate event handlers have been dispatched (allowing these event listeners to add or remove additional listeners on other objects in an event's propagation chain, but not affect the order of listeners that will be invoked on the target object). and from DOM Living Standard (step for invoke algorithm) 2. Let listeners be a copy of the event listeners associated with the object for which these steps are run. So, if I understand all, we can from actual listener add/remove new listener for other objects in an event's propagation chain (next) and its will execute for this dispath event, but if we add/remove next listener from actual target its should not execute for this propagation, but can be execute when events dispatch again. Ok, I saw in past that someone write about this bug, but only when we add listener and for this its work fine (like other browser). But when we remove listener I think its not correct, because we can delete next listener from first listener for actual target, and this listener not execute (for actual dispatch event). <!DOCTYPE html> <html> <head> <script> // Uruchom po całkowitym załadowaniu dokumentu window.onload = function(){ var button = document.getElementById("press"); var info = document.getElementById("info"); var test1 = function(){ info.innerHTML += "First add listener for button." + "<br><br>"; }; var test2 = function(){ info.innerHTML += "Second add listener for button." + "<br><br>"; }; button.addEventListener("click", function(e){ info.innerHTML += "Start listener for button." + "<br><br>"; button.removeEventListener("click", test1, false); // it happend for first click (bug) button.removeEventListener("click", test2, false); // it happend for first click (bug) }, false); button.addEventListener("click", test1); button.addEventListener("click", test2); } </script> </head> <body> <p>Press the button.</p> <input id="press" type="button" value="Click me!" > <p style="color: blue;">More info:</p> <p id="info"></p> </body> </html> I test this behaviour in other browser and Chrome, Firefox, Opera (Presto) let remove listener for current target in actual step for event (its wrong), but only IE doing it the right way. So, if we cant add next listener for actual target and execute this for actual dispatch event then the same behaviour should be for remove listener. Although it is possible that I did not understand well the specification, so I look forward to comments. Actual results: For first click: Start listener for button. For next click: Start listener for button. Expected results: For first click: Start listener for button. First add listener for button. Second add listener for button. For next click: Start listener for button.
Summary: Modify candidate (remove) event listeners is wrong → Modify (remove) candidate event listeners is wrong
Attached file 906608.html
Now it's not actual, spec has been changed to cover this case: https://github.com/whatwg/dom/issues/84
Arkadiusz, I clearly should have investigated this better when you first reported it. My apologies.
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: