When several event listeners with once option are attached to an element and each one uses event.stopImmediatePropagation(), they are removed in pairs
Reported by
world617...@gmail.com,
Sep 29
|
||
Issue descriptionUserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36 Steps to reproduce the problem: 1. Use document.querySelector to get an element 2. Attach several event listeners to the element with an option 'once' set to true. 3. Use event.stopImmediatePropagation() inside each listener to prevent the execution of all event listeners at the same time. 4. Trigger the event either manually or by code (e.g. if listeners set for 'click' event, then by element.click() method) What is the expected behavior? Only one listener should be execute when event is triggered and only once. The execution order should match the order they were attached to the element. Firefox (62.0.2 64-bit) and Edge (Microsoft EdgeHTML 17.17134) have the described behaviour. What went wrong? After the first event with once option being executed the number of removed event is not one but two (the second event listener also is removed). The described behaviour is true for every pair of event listeners attached to one element. So if 3 event listeners are attached to an element, only 2 of them will be executed while 3 removed. The executed ones will be the first and the third listeners. Checked with Event Listeners section of the Elements tab in Chrome DevTools. Did this work before? N/A Does this work in other browsers? Yes Chrome version: 69.0.3497.100 Channel: stable OS Version: 10.0 Flash Version: I wasn't sure what exactly 'reduced test case' means so I provided a .html file with code relevant to the problem. Example allow to recreate the described issue.
,
Oct 25
cc yukishiino@ in case it was due to recent changes to EventListeners? |
||
►
Sign in to add a comment |
||
Comment 1 by phistuck@chromium.org
, Sep 29