mirror of https://github.com/sveltejs/svelte
fix: ensure `$effect.root` is ignored on the server (#12332)
Ignore the contents of the effect root, just return a noop where necessary fixes #12322pull/12340/head
parent
cf16acda32
commit
243c4b78b1
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: ensure `$effect.root` is ignored on the server
|
@ -0,0 +1,18 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: '<button>cleanup</button>',
|
||||
|
||||
async test({ assert, target, logs }) {
|
||||
const btn = target.querySelector('button');
|
||||
|
||||
btn?.click();
|
||||
flushSync();
|
||||
|
||||
assert.deepEqual(logs, ['effect1', 'effect2']);
|
||||
},
|
||||
test_ssr({ assert, logs }) {
|
||||
assert.deepEqual(logs, []);
|
||||
}
|
||||
});
|
@ -0,0 +1,10 @@
|
||||
<script>
|
||||
$effect.root(() => {
|
||||
console.log('effect1');
|
||||
});
|
||||
const cleanup = $effect.root(() => {
|
||||
console.log('effect2');
|
||||
});
|
||||
</script>
|
||||
|
||||
<button onclick={cleanup}>cleanup</button>
|
Loading…
Reference in new issue