mirror of https://github.com/sveltejs/svelte
fix: prevent false-positive reactivity loss warning (#18373)
By checking that current/previous batch are null we filter out false positives. `reactivity_loss_tracker` is only reset after a microtask, so if a flush happens before that, we get warnings for things we shouldn't warn on. Fixes #18370 --------- Co-authored-by: Rich Harris <rich.harris@vercel.com>pull/18357/head
parent
bdb1a0f847
commit
3d5c4ab620
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: prevent false-positive reactivity loss warning
|
||||
@ -0,0 +1,15 @@
|
||||
import { tick } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
compileOptions: { dev: true },
|
||||
async test({ assert, target, warnings }) {
|
||||
await tick();
|
||||
const [increment] = target.querySelectorAll('button');
|
||||
|
||||
increment.click();
|
||||
await new Promise((resolve) => setTimeout(resolve, 10));
|
||||
assert.htmlEqual(target.innerHTML, '<button>increment</button> 1 1');
|
||||
assert.deepEqual(warnings, []);
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,16 @@
|
||||
<script>
|
||||
let x = $state(0);
|
||||
let y = $state(0);
|
||||
</script>
|
||||
|
||||
<button
|
||||
onclick={() => {
|
||||
x++;
|
||||
queueMicrotask(() => queueMicrotask(() => y++));
|
||||
}}
|
||||
>
|
||||
increment
|
||||
</button>
|
||||
|
||||
{await x}
|
||||
{y}
|
||||
Loading…
Reference in new issue