mirror of https://github.com/sveltejs/svelte
fix: prevent infinite loops stemming from invalidation method (#9811)
* fix: prevent infinite loops stemming from invalidation method The logic was flawed: the captured signals where always added to the previous captured no matter what, which meant a) memory leak b) that when another one runs afterwards, it will falsely contain the signals from the previous run fixes #9788 * fix lintpull/9821/head
parent
edc569e73b
commit
074615d7fd
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: prevent infinite loops stemming from invalidation method
|
@ -0,0 +1,32 @@
|
|||||||
|
import { flushSync } from 'svelte';
|
||||||
|
import { ok, test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
html: `
|
||||||
|
<select>
|
||||||
|
<option value="a">A</option>
|
||||||
|
<option value="b">B</option>
|
||||||
|
</select>
|
||||||
|
selected: a
|
||||||
|
`,
|
||||||
|
|
||||||
|
test({ assert, target }) {
|
||||||
|
const select = target.querySelector('select');
|
||||||
|
ok(select);
|
||||||
|
const event = new window.Event('change');
|
||||||
|
select.value = 'b';
|
||||||
|
select.dispatchEvent(event);
|
||||||
|
flushSync();
|
||||||
|
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<select>
|
||||||
|
<option value="a">A</option>
|
||||||
|
<option value="b">B</option>
|
||||||
|
</select>
|
||||||
|
selected: b
|
||||||
|
`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,11 @@
|
|||||||
|
<script>
|
||||||
|
let entries = [{selected: 'a' }]
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#each entries as entry}
|
||||||
|
<select bind:value={entry.selected}>
|
||||||
|
<option value='a'>A</option>
|
||||||
|
<option value='b'>B</option>
|
||||||
|
</select>
|
||||||
|
selected: {entry.selected}
|
||||||
|
{/each}
|
Loading…
Reference in new issue