fix: do not dispatch transition event with animation
#18122
Closing issue
Describe the bug
The onintrostart event fires when an element begins an animation specified with animate:.
This bug was introduced by #17567.
The best solution appears to be moving back the dispatchEvent() calls in packages/svelte/src/internal/client/dom/elements/transitions.js to the transition() function. Otherwise, we would probably need to add a parameter to animate(), indicating whether it was called by transition(), which may be a little dirty.
Maybe, we could add an on_begin callback parameter to animate(), which is how dispatchEvent() could be triggered to not break the fix of #14009. I can create a PR for this in case you like the solution :D
Reproduction
https://svelte.dev/playground/1b1bf2a52c2448a09917378711735c3d?version=5.55.1
Logs
System Info
System:
OS: Linux 6.17 Ubuntu 25.10 25.10 (Questing Quokka)
CPU: (6) x64 AMD Ryzen 5 4500U with Radeon Graphics
Memory: 1008.57 MB / 6.67 GB
Container: Yes
Shell: 5.9 - /usr/bin/zsh
Binaries:
Node: 22.21.1 - /home/dabund24/.nvm/versions/node/v22.21.1/bin/node
npm: 10.9.4 - /home/dabund24/.nvm/versions/node/v22.21.1/bin/npm
Browsers:
Firefox: 149.0
Firefox Developer Edition: 149.0
npmPackages:
svelte: ^5.55.0 => 5.55.1
Severity
blocking an upgrade
Pull request
closes #18056 related: #17567 and #14009
Changes
move dispatch_event() calls in transitions.js out of animate() function using an additional on_begin() callback parameter. Doing so makes it possible to dispatch the introstart and outrostart events only from transition().
Testing
add a test checking that svelte dispatches no event when it runs an animation
Info
🦋 Changeset detected
Latest commit: be10223
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
| Name | Type |
|---|---|
| svelte | Patch |
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
Pro tip: You can prefix GitHub URLs of issues, PRs or discussions with svcl.dev/ to view them on this page! Also try it on a GitHub release ;)