LibWeb/CSS: Use dimension_for_unit() when we don't need the exact unit

A small code reduction, and means that NumericType will catch if new
dimensions are added, and attr() will just work in that case.
This commit is contained in:
Sam Atkins 2025-09-02 13:58:20 +01:00
commit b3c099bd68
Notes: github-actions[bot] 2025-09-11 16:08:10 +00:00
2 changed files with 28 additions and 35 deletions

View file

@ -131,12 +131,7 @@ static Vector<ComponentValue> replace_an_attr_function(DOM::AbstractElement& ele
first_argument_tokens.discard_a_token(); // raw-string
syntax = RawString {};
} else if (syntax_ident == "%"sv
|| string_to_angle_unit(syntax_ident).has_value()
|| string_to_flex_unit(syntax_ident).has_value()
|| string_to_frequency_unit(syntax_ident).has_value()
|| string_to_length_unit(syntax_ident).has_value()
|| string_to_resolution_unit(syntax_ident).has_value()
|| string_to_time_unit(syntax_ident).has_value()) {
|| dimension_for_unit(syntax_ident).has_value()) {
syntax = TypeSyntaxNode::create("number"_fly_string).release_nonnull<SyntaxNode>();
unit_name = first_argument_tokens.consume_a_token().token().ident();
} else {