mirror of https://github.com/sveltejs/svelte
fix: maintain correct linked list of effects when updating each blocks (#17191)
* fix: maintain correct linked list of effects when updating each blocks * working * tidy up * changeset * remove unnecessary assignment, add comment explaining unidirectionalitypull/17192/head
parent
92c936d9b3
commit
e365890ef9
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: maintain correct linked list of effects when updating each blocks
|
||||
@ -0,0 +1,32 @@
|
||||
import { tick } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, target }) {
|
||||
const [step_back, step_forward, jump_back, jump_forward] = target.querySelectorAll('button');
|
||||
const [div] = target.querySelectorAll('div');
|
||||
|
||||
step_back.click();
|
||||
await tick();
|
||||
|
||||
step_forward.click();
|
||||
await tick();
|
||||
|
||||
step_forward.click();
|
||||
await tick();
|
||||
|
||||
// if the effects get linked in a circle, we will never get here
|
||||
assert.htmlEqual(div.innerHTML, '<p>5</p><p>6</p><p>7</p>');
|
||||
|
||||
jump_forward.click();
|
||||
await tick();
|
||||
|
||||
step_forward.click();
|
||||
await tick();
|
||||
|
||||
step_forward.click();
|
||||
await tick();
|
||||
|
||||
assert.htmlEqual(div.innerHTML, '<p>12</p><p>13</p><p>14</p>');
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,33 @@
|
||||
<script lang="ts">
|
||||
let items = $state([4, 5, 6]);
|
||||
</script>
|
||||
|
||||
<button onclick={() => {
|
||||
items = items.map((n) => n - 1);
|
||||
}}>
|
||||
step back
|
||||
</button>
|
||||
|
||||
<button onclick={() => {
|
||||
items = items.map((n) => n + 1);
|
||||
}}>
|
||||
step forward
|
||||
</button>
|
||||
|
||||
<button onclick={() => {
|
||||
items = items.map((n) => n - 5);
|
||||
}}>
|
||||
jump back
|
||||
</button>
|
||||
|
||||
<button onclick={() => {
|
||||
items = items.map((n) => n + 5);
|
||||
}}>
|
||||
jump forward
|
||||
</button>
|
||||
|
||||
<div>
|
||||
{#each items as item (item)}
|
||||
<p>{item}</p>
|
||||
{/each}
|
||||
</div>
|
||||
Loading…
Reference in new issue