diff --git a/src/ExCSS/Extensions/ValueExtensions.cs b/src/ExCSS/Extensions/ValueExtensions.cs index 8f1f97b..6f20555 100644 --- a/src/ExCSS/Extensions/ValueExtensions.cs +++ b/src/ExCSS/Extensions/ValueExtensions.cs @@ -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); }