From ad7d6bc23d07109d29cee92b74f710319c6129b0 Mon Sep 17 00:00:00 2001 From: 0z5a Date: Wed, 18 Nov 2026 21:43:27 +0100 Subject: [PATCH] fix: render an infinite Animation count as `infinite` `count: double.infinity` was rendered as `infinity`, which is not a valid `animation-iteration-count`, so the browser dropped the whole `animation` declaration. Fixes #919 --- packages/jaspr/CHANGELOG.md | 1 + .../jaspr/lib/src/dom/styles/properties/animation.dart | 3 ++- .../jaspr/test/dom/styles/properties/animation_test.dart | 9 ++++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/jaspr/CHANGELOG.md b/packages/jaspr/CHANGELOG.md index e05351023..1887b6b72 100644 --- a/packages/jaspr/CHANGELOG.md +++ b/packages/jaspr/CHANGELOG.md @@ -77,6 +77,7 @@ - Fixed hydration of nullable `@client` parameters that use custom codecs when their value is `null`. - Fixed the server output of a client component that renders `` when the document has no ``. - Fixed the `hasOuterHtml` matcher from `jaspr_test` never matching when compiled to Wasm. +- Fixed `Animation(count: double.infinity)` rendering `infinity` instead of `infinite`, which made the browser drop the whole `animation` declaration. ## 0.23.5 diff --git a/packages/jaspr/lib/src/dom/styles/properties/animation.dart b/packages/jaspr/lib/src/dom/styles/properties/animation.dart index 2298d43af..0115ecdbc 100644 --- a/packages/jaspr/lib/src/dom/styles/properties/animation.dart +++ b/packages/jaspr/lib/src/dom/styles/properties/animation.dart @@ -62,7 +62,8 @@ class _Animation implements Animation { var val = '${duration.inMilliseconds}ms'; if (curve != null) val += ' ${curve!.value}'; if (delay != null) val += ' ${delay!.inMilliseconds}ms'; - if (count != null) val += ' ${count!.numstr}'; + // `animation-iteration-count` takes the keyword `infinite`, not `infinity`. + if (count != null) val += ' ${count!.isInfinite ? 'infinite' : count!.numstr}'; if (direction != null) val += ' ${direction!.value}'; if (fillMode != null) val += ' ${fillMode!.value}'; if (playState != null) val += ' ${playState!.value}'; diff --git a/packages/jaspr/test/dom/styles/properties/animation_test.dart b/packages/jaspr/test/dom/styles/properties/animation_test.dart index f188de810..b53d220c2 100644 --- a/packages/jaspr/test/dom/styles/properties/animation_test.dart +++ b/packages/jaspr/test/dom/styles/properties/animation_test.dart @@ -28,11 +28,18 @@ void main() { expect( styles.properties, equals({ - 'animation': '500ms linear(0.2 30% 60%, 0.3 40% 80.5%) 100ms infinity normal forwards running slide', + 'animation': '500ms linear(0.2 30% 60%, 0.3 40% 80.5%) 100ms infinite normal forwards running slide', }), ); }); + test('finite count', () { + const styles = Styles( + animation: Animation(name: 'pulse', duration: Duration(seconds: 1), count: 2.5), + ); + expect(styles.properties, equals({'animation': '1000ms 2.5 pulse'})); + }); + group('combine', () { test('basic', () { const animations = Animation.list([