diff --git a/lib/utils/debounce.html b/lib/utils/debounce.html
index ad6b98ff95..54fc859623 100644
--- a/lib/utils/debounce.html
+++ b/lib/utils/debounce.html
@@ -127,6 +127,8 @@
* @return {void}
*/
Polymer.enqueueDebouncer = function(debouncer) {
+ // Re-enqueued debouncers are put at the end of the queue; for Set, this
+ // means removing and re-adding, since forEach traverses insertion order
if (debouncerQueue.has(debouncer)) {
debouncerQueue.delete(debouncer);
}
@@ -135,6 +137,8 @@
Polymer.flushDebouncers = function() {
const didFlush = Boolean(debouncerQueue.size);
+ // If new debouncers are added while flushing, Set.forEach will ensure
+ // newly added ones are also flushed
debouncerQueue.forEach(debouncer => {
try {
debouncer.flush();