mirror of https://github.com/sveltejs/svelte
Merge ecc624e11f into af5b9724ab
commit
581884da3c
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
fix: preserve `bind:this` values in effect teardown
|
||||
@ -0,0 +1,11 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
test({ assert, target, logs }) {
|
||||
target.querySelector('button')?.click();
|
||||
flushSync();
|
||||
|
||||
assert.deepEqual(logs, ['INPUT']);
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,18 @@
|
||||
<script>
|
||||
let input = $state(null);
|
||||
let show = $state(true);
|
||||
|
||||
$effect(() => {
|
||||
input;
|
||||
|
||||
return () => {
|
||||
console.log(input === null ? 'null' : input.tagName);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<button onclick={() => (show = false)}>hide</button>
|
||||
|
||||
{#if show}
|
||||
<input bind:this={input} />
|
||||
{/if}
|
||||
Loading…
Reference in new issue