Skip to content

fix: avoid NaN keyframe values in slide transition#18430

Open
Nic-Polumeyv wants to merge 1 commit into
sveltejs:mainfrom
Nic-Polumeyv:fix-slide-nan-keyframes
Open

fix: avoid NaN keyframe values in slide transition#18430
Nic-Polumeyv wants to merge 1 commit into
sveltejs:mainfrom
Nic-Polumeyv:fix-slide-nan-keyframes

Conversation

@Nic-Polumeyv

@Nic-Polumeyv Nic-Polumeyv commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Fixes #14205

When a slide transition runs on an element without a layout box, for example inside a display: none parent, getComputedStyle returns values like auto for the animated dimensions. These were passed through parseFloat unguarded, so the generated css contained height: NaNpx and the browser rejected the keyframe property with an "Invalid keyframe value" warning on every transition.

Svelte 4 had the same NaN but never surfaced it, because invalid declarations in injected stylesheet rules are silently dropped, while the Web Animations API validates keyframes and warns.

This treats unparseable computed dimensions as 0. The user visible result is the same as today (the browser was already discarding the invalid property, and an element with no layout box has nothing to slide), minus the console spam.


  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.
  • If this PR changes code within packages/svelte/src, add a changeset (npx changeset)

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

@changeset-bot

changeset-bot Bot commented Jun 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a2243be

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slide transition throws a "Invalid keyframe value for property height" warning since Svelte 5

1 participant