mirror of https://github.com/sveltejs/svelte
fix: further improvements to effect scheduling and flushing (#10971)
* fix: improve effect scheduling * fix: further improvements to effect scheduling and flushin * add test * simplify * simplify * lint * fix e2e tests * fix e2e tests * simplify * Update packages/svelte/src/internal/client/runtime.js * Update packages/svelte/src/internal/client/runtime.js Co-authored-by: Rich Harris <rich.harris@vercel.com> * Update packages/svelte/src/internal/client/runtime.js Co-authored-by: Rich Harris <rich.harris@vercel.com> * Update packages/svelte/src/internal/client/runtime.js Co-authored-by: Rich Harris <rich.harris@vercel.com> * style tweak --------- Co-authored-by: Rich Harris <rich.harris@vercel.com>pull/10977/head
parent
293f905a53
commit
8971910940
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
fix: further improvements to effect scheduling and flushing
|
@ -0,0 +1,24 @@
|
||||
<script>
|
||||
import {beforeUpdate} from 'svelte';
|
||||
|
||||
let count1 = 0;
|
||||
let count2 = 0;
|
||||
|
||||
function increaseCount1() {
|
||||
count1++;
|
||||
}
|
||||
|
||||
$: if (count2 < 10) {
|
||||
increaseCount1();
|
||||
}
|
||||
|
||||
$: if (count1 < 10) {
|
||||
count2++;
|
||||
}
|
||||
|
||||
beforeUpdate(() => {
|
||||
// We don't need to do anything
|
||||
});
|
||||
</script>
|
||||
|
||||
<button on:click={() => count1++}>{count1} / {count2}</button>
|
@ -0,0 +1,11 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, component, target }) {
|
||||
const [btn1] = target.querySelectorAll('button');
|
||||
flushSync(() => {
|
||||
// This test would result in an infinite loop, so if this doesn't error, then the test is working.
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,9 @@
|
||||
<script>
|
||||
import Item from './Item.svelte';
|
||||
|
||||
var items = Array(1000);
|
||||
</script>
|
||||
|
||||
{#each items as item}
|
||||
<Item />
|
||||
{/each}
|
Loading…
Reference in new issue