-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
fix: ensure custom elements do not sync flush on mount #12787
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
Conversation
🦋 Changeset detectedLatest commit: bfa02a3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
This would be a big breaking change for everyone else, I don't think we can do that. If we determine this needs to be fixed for custom elements somehow, then the flush_sync should only be avoided for the custom element wrappers |
Updated it so it only happens for non custom-element wrappers. |
|
I tweaked the test so it fails on main. The event handler needs to be added on after the first |
|
ah whoops, gotcha — thought it was just about delaying the check until both the element upgrade and the effect |
Fixes #12772.
We currently have an inconsistency around using
$effecttogether with custom elements. If you put in an$effectinside a custom element, then we flush the effects sync before moving on the handling the next custom element. This is problematic when you have things like event handlers or other sequence/propagation sensitive things around as normally effects happen after we write we've handled the DOM, not incrementally as we're handling the DOM.This is compounded if someone were to have
$effect.prein one custom element that is a parent of a child that has an$effect, the child$effectwould run before the parent$effect.prewhich makes for glitchy behaviour when creating interactions that depend on the correct ordering.To fix this, we remove the problematic
flush_syncfromSvelte4Component. If people want to force their custom elements to work sync, they can always manuallyflush_syncthemselves, however that's rarely needed.