Skip to content

fix: render an infinite Animation count as infinite - #1005

Open
0z5a wants to merge 1 commit into
schultek:nextfrom
0z5a:fix-infinite-animation-count
Open

0z5a wants to merge 1 commit into
schultek:nextfrom
0z5a:fix-infinite-animation-count

Conversation

@0z5a

@0z5a 0z5a commented Nov 18, 2026

Copy link
Copy Markdown

Description

Fixes #919

I started from #919 and checked it against the code on next. _Animation.value renders the iteration count with count!.numstr, and numstr returns toString().toLowerCase() for infinite values, so count: double.infinity becomes infinity. animation-iteration-count only accepts the keyword infinite, so the browser cannot parse the shorthand and drops the whole animation declaration, as the issue describes.

The change renders an infinite count as infinite in _Animation.value and leaves numstr alone, since its other callers (units, angles, transforms) still need infinity, which is the valid keyword inside calc(). The existing basic test was asserting the broken infinity output, so it now expects infinite, and a new finite count test keeps the plain number path covered.

This follows the approach that was approved on #923, rebased onto next as requested there.

How I found it

I read _Animation.value in animation.dart and followed numstr to unit.dart. The isInfinite branch there is what turns double.infinity into infinity. Animation.count is a double?, so double.infinity is the only way to ask for an endless loop with the typed API.

Where this can show up in practice

Any site that uses Animation(..., count: double.infinity) for a looping animation, such as a spinner or a pulsing placeholder, gets no animation at all and no error at build time or in the console. This is my estimate beyond the report in #919.

Type of Change

  • 🛠️ Bug fix

Testing

  • dart test -p vm test/dom/ in packages/jaspr passes (138 tests). With the source change reverted, animation_test.dart fails on the new infinite expectation.
  • dart analyze --fatal-infos reports no issues for the two changed Dart files, and dart format --line-length 120 leaves them unchanged.
  • This ran on Linux arm64 with Dart 3.14.1 in Docker. The Flutter packages, apps and examples were left out of the workspace for dart pub get there, because that image has no Flutter SDK.
  • Not run: the browser tests, melos run coverage, and a check in a real browser.

Ready Checklist

  • I've read the Contribution Guide.
  • In case this PR changes one of the core packages, I've modified the respective CHANGELOG.md file using
    the semantic_changelog format.
  • I updated/added relevant documentation (doc comments with ///).
  • I added myself to the AUTHORS file (optional, if you want to).

`count: double.infinity` was rendered as `infinity`, which is not a valid `animation-iteration-count`, so the browser dropped the whole `animation` declaration.

Fixes schultek#919
@0z5a
0z5a requested a review from schultek as a code owner November 18, 2026 20:43
Copilot AI balanced review requested due to automatic review settings November 18, 2026 20:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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.

2 participants