Skip to content

Commit

Permalink
Fixed percent fraction extension and test
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerBrinks committed Sep 23, 2024
1 parent d7d20d3 commit a80495b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/ExCSS/Extensions/ValueExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,15 @@ public static Length ToLength(this FontSize fontSize)
return percent;
}

var element = enumerable.OnlyOrDefault();

if (element is not { Type: TokenType.Percentage })
var element = value.OnlyOrDefault();
if (element is not NumberToken token)
{
return null;
}

var number = ((NumberToken)element).Value;

try
{
var number = token.Value;
var percentage = number / 100;
return new Percent(percentage);
}
Expand Down

0 comments on commit a80495b

Please sign in to comment.