Internals: Scheduler: Fix infinite loop in flush (#4316)

pull/4326/head
David Kondrad 5 years ago committed by Conduitry
parent bf006a43e5
commit 8e245dc30e

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

@ -0,0 +1,6 @@
export default {
test({ assert, component }) {
const { count } = component;
assert.deepEqual(count, 1);
}
};

@ -0,0 +1,16 @@
<script>
import { onMount } from 'svelte';
import Child from './Child.svelte';
let root;
export let count = 0;
onMount(() => {
if (count < 5) {
count++;
new Child({ target: root });
}
});
</script>
<div bind:this={root}></div>
Loading…
Cancel
Save