Skip to content

Commit

Permalink
Fixed keyframe stop truncation AngleSharp#128
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianRappl committed Jun 14, 2023
1 parent 6905fa5 commit 1f3d718
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Released on tbd.
- Fixed issue when updating shorthands with invalid values (#129)
- Fixed issue with appended EOF character in `CssText` (#123)
- Fixed missing semicolon in `@page` rule (#135)
- Fixed integer serialization of keyframe stops (#128)

# 0.17.0

Expand Down
12 changes: 11 additions & 1 deletion src/AngleSharp.Css.Tests/Rules/CssKeyframeRule.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace AngleSharp.Css.Tests.Rules
namespace AngleSharp.Css.Tests.Rules
{
using NUnit.Framework;
using System.Linq;
Expand Down Expand Up @@ -74,5 +74,15 @@ public void KeyframeRuleWith0AndNoDeclarations()
Assert.AreEqual(1, rule.Key.Stops.Count());
Assert.AreEqual(0, rule.Style.Length);
}

[Test]
public void KeyframeRuleWithPercentage_Issue128()
{
var rule = ParseKeyframeRule(@" 0.52%, 50.0%,92.82% { }");
Assert.IsNotNull(rule);
Assert.AreEqual("0.52%, 50%, 92.82%", rule.KeyText);
Assert.AreEqual(3, rule.Key.Stops.Count());
Assert.AreEqual(0, rule.Style.Length);
}
}
}
2 changes: 1 addition & 1 deletion src/AngleSharp.Css/Dom/Internal/KeyframeSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void ToCss(TextWriter writer, IStyleFormatter formatter)

private static void Write(TextWriter writer, Double value)
{
var pc = Math.Truncate(100.0 * value);
var pc = 100.0 * value;
var str = pc.ToString(CultureInfo.InvariantCulture);
writer.Write(str);
writer.Write(Symbols.Percent);
Expand Down

0 comments on commit 1f3d718

Please sign in to comment.