fix: ensure user effects are correctly executed on initialisation (#13697)

pull/13696/head
Dominic Gannaway 2 months ago committed by GitHub
parent ae10f4d37c
commit 2ca9a81679
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: ensure user effects are correctly executed on initialisation

@ -192,8 +192,7 @@ export function user_effect(fn) {
// until the component is mounted // until the component is mounted
var defer = var defer =
active_effect !== null && active_effect !== null &&
(active_effect.f & RENDER_EFFECT) !== 0 && (active_effect.f & BRANCH_EFFECT) !== 0 &&
// TODO do we actually need this? removing them changes nothing
component_context !== null && component_context !== null &&
!component_context.m; !component_context.m;

@ -0,0 +1,7 @@
import { test } from '../../test';
export default test({
async test({ assert, logs }) {
assert.deepEqual(logs, ['effect 1', 'effect 2']);
}
});

@ -0,0 +1,15 @@
<script>
$effect.pre(() => {
$effect(() => {
console.log('effect 1')
})
})
function template() {
$effect(() => {
console.log('effect 2')
});
}
</script>
{template()}
Loading…
Cancel
Save