mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
flush without recursion
This commit is contained in:
parent
f20cc83f7f
commit
ae34824c94
@ -32,12 +32,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
}
|
||||
|
||||
function flushQueue(queue) {
|
||||
for (let i=0, q, context, callback, args; i<queue.length; i++) {
|
||||
while (queue.length) {
|
||||
const q = queue.shift();
|
||||
const context = q[0];
|
||||
const callback = q[1];
|
||||
const args = q[2];
|
||||
try {
|
||||
q = queue[i];
|
||||
context = q[0];
|
||||
callback = q[1];
|
||||
args = q[2];
|
||||
callback.apply(context, args);
|
||||
} catch(e) {
|
||||
setTimeout(() => {
|
||||
@ -45,14 +45,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
})
|
||||
}
|
||||
}
|
||||
queue.length = 0;
|
||||
}
|
||||
|
||||
function flush() {
|
||||
flushQueue(beforeRenderQueue);
|
||||
flushQueue(afterRenderQueue);
|
||||
if (beforeRenderQueue.length || afterRenderQueue.length) {
|
||||
flush();
|
||||
while (beforeRenderQueue.length || afterRenderQueue.length) {
|
||||
flushQueue(beforeRenderQueue);
|
||||
flushQueue(afterRenderQueue);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user