* update function notifyListeners in events.js

newEventListenerList will delete wrong listener if it call splice method in for-loop.

* Update events.js

---------

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
This commit is contained in:
Hao
2023-02-25 12:58:59 +11:00
committed by GitHub
co-authored by Lea Anthony
parent dcfd525dd1
commit 0212698714
@@ -97,7 +97,7 @@ function notifyListeners(eventData) {
const newEventListenerList = eventListeners[eventName].slice();
// Iterate listeners
for (let count = 0; count < eventListeners[eventName].length; count += 1) {
for (let count = eventListeners[eventName].length - 1; count >= 0; count -= 1) {
// Get next listener
const listener = eventListeners[eventName][count];