mirror of https://github.com/sveltejs/svelte
fix: don't access inert block effects (#17882)
In #17837 we added logic to not schedule another batch during
resumption. The logic in there turns out to be flawed - it's dangerous
to keep accessing inert block effects, because if they're nested they
could access properties that no longer exist (because the outer if makes
the inner if obsolete).
So this PR basically reverts #17837 and instead schedules another batch
again under the assumption that this will only happen during the commit
phase, and all that's gonna happen is that it will schedule another
batch, which is safe.
Fixes #17866 Fixes #17878
This reverts commit 2f12b60701.
Co-authored-by: Rich Harris <rich.harris@vercel.com>
pull/17854/head
parent
1304208970
commit
1892988074
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: don't access inert block effects
|
||||
@ -0,0 +1,14 @@
|
||||
import { tick } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
import { raf } from '../../../animation-helpers';
|
||||
|
||||
export default test({
|
||||
async test({ assert, target }) {
|
||||
const [btn] = target.querySelectorAll('button');
|
||||
|
||||
btn.click();
|
||||
await tick();
|
||||
raf.tick(100);
|
||||
assert.htmlEqual(target.innerHTML, `<button>clear</button>`);
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,17 @@
|
||||
<script>
|
||||
import { fade } from 'svelte/transition';
|
||||
|
||||
let data = $state({ id: 1 });
|
||||
</script>
|
||||
|
||||
<button onclick={() => (data = null)}>clear</button>
|
||||
|
||||
{#if data}
|
||||
{#key data?.id}
|
||||
<p transition:fade|global={{ duration: 100 }}>keyed</p>
|
||||
{/key}
|
||||
|
||||
{#if data.id}
|
||||
<p>sibling</p>
|
||||
{/if}
|
||||
{/if}
|
||||
Loading…
Reference in new issue