From f4df46634213dbc1528e438ac7fef4169979e1b3 Mon Sep 17 00:00:00 2001 From: Kevin Schaaf Date: Wed, 27 Feb 2019 15:48:09 -0800 Subject: [PATCH] Add comments --- lib/utils/debounce.html | 4 ++++ 1 file changed, 4 insertions(+) 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();