Ensure pending callbacks are called only once

This commit is contained in:
Raymond Hill 2021-06-24 11:08:55 -04:00
parent 10efc35610
commit 0dbe581c5b
No known key found for this signature in database
GPG key ID: 25E1490B761470C2

View file

@ -85,16 +85,20 @@
setTimeout(item.eventCallback, 1);
};
if ( Array.isArray(dl) ) {
for ( const item of dl ) {
dl.push = item => doCallback(item);
const q = dl.slice();
dl.length = 0;
for ( const item of q ) {
doCallback(item);
}
}
dl.push = item => doCallback(item);
}
}
// empty ga queue
if ( gaQueue instanceof Function && Array.isArray(gaQueue.q) ) {
for ( const entry of gaQueue.q ) {
const q = gaQueue.q.slice();
gaQueue.q.length = 0;
for ( const entry of q ) {
ga(...entry);
}
}