-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
$effect
together with custom elements. If you put in an$effect
inside 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.pre
in one custom element that is a parent of a child that has an$effect
, the child$effect
would run before the parent$effect.pre
which makes for glitchy behaviour when creating interactions that depend on the correct ordering.To fix this, we remove the problematic
flush_sync
fromSvelte4Component
. If people want to force their custom elements to work sync, they can always manuallyflush_sync
themselves, however that's rarely needed.