internal: scheduler: fix usage of seen_callbacks

The set that was added to block infinite loops wasn't actually doing anything.
Lift the declaration outside of the function and clear it at the end.
pull/4316/head
David A Kondrad 6 years ago
parent 164622ea64
commit 7f85b929d8

@ -31,8 +31,8 @@ export function add_flush_callback(fn) {
flush_callbacks.push(fn); flush_callbacks.push(fn);
} }
const seen_callbacks = new Set();
export function flush() { export function flush() {
const seen_callbacks = new Set();
do { do {
// first, call beforeUpdate functions // first, call beforeUpdate functions
@ -52,10 +52,10 @@ export function flush() {
const callback = render_callbacks[i]; const callback = render_callbacks[i];
if (!seen_callbacks.has(callback)) { if (!seen_callbacks.has(callback)) {
callback();
// ...so guard against infinite loops // ...so guard against infinite loops
seen_callbacks.add(callback); seen_callbacks.add(callback);
callback();
} }
} }
@ -67,6 +67,7 @@ export function flush() {
} }
update_scheduled = false; update_scheduled = false;
seen_callbacks.clear();
} }
function update($$) { function update($$) {

@ -13,4 +13,4 @@
}); });
</script> </script>
<div bind:this={root}></div> <div bind:this={root}></div>

Loading…
Cancel
Save