Skip to content

breaking: always run pre effects synchronously #10928

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/few-clouds-shop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

breaking: always run pre effects immediately
5 changes: 2 additions & 3 deletions packages/svelte/src/internal/client/reactivity/effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,8 @@ export function pre_effect(fn) {
: '')
);
}
const sync = current_effect !== null && (current_effect.f & RENDER_EFFECT) !== 0;

return create_effect(PRE_EFFECT, fn, sync);
return create_effect(PRE_EFFECT, fn, true);
}

/**
Expand Down Expand Up @@ -206,7 +205,7 @@ export function render_effect(fn, managed = false) {
let flags = RENDER_EFFECT;
if (managed) flags |= MANAGED;

return create_effect(flags, /** @type {any} */ (fn), true);
return create_effect(flags, fn, true);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ export default test({

assert.deepEqual(log, [
'Outer Effect Start (0)',
'Outer Effect End (0)',
'Inner Effect (0)',
'Outer Effect End (0)',
'Outer Effect Start (1)',
'Outer Effect End (1)',
'Inner Effect (1)',
'Outer Effect End (1)',
'Outer Effect Start (2)',
'Outer Effect End (2)',
'Inner Effect (2)'
'Inner Effect (2)',
'Outer Effect End (2)'
]);
}
});