@@ -564,8 +564,8 @@ where
564
564
{
565
565
let ( red, green, blue, uses_commas) = match_ignore_ascii_case ! { name,
566
566
"rgb" | "rgba" => parse_rgb_components_rgb( component_parser, arguments) ?,
567
- "hsl" | "hsla" => parse_hsl_hwb( component_parser, arguments, hsl_to_rgb) ?,
568
- "hwb" => parse_hsl_hwb( component_parser, arguments, hwb_to_rgb) ?,
567
+ "hsl" | "hsla" => parse_hsl_hwb( component_parser, arguments, hsl_to_rgb, /* allow_comma = */ true ) ?,
568
+ "hwb" => parse_hsl_hwb( component_parser, arguments, hwb_to_rgb, /* allow_comma = */ false ) ?,
569
569
_ => return Err ( arguments. new_unexpected_token_error( Token :: Ident ( name. to_owned( ) . into( ) ) ) ) ,
570
570
} ;
571
571
@@ -633,6 +633,7 @@ fn parse_hsl_hwb<'i, 't, ComponentParser>(
633
633
component_parser : & ComponentParser ,
634
634
arguments : & mut Parser < ' i , ' t > ,
635
635
to_rgb : impl FnOnce ( f32 , f32 , f32 ) -> ( f32 , f32 , f32 ) ,
636
+ allow_comma : bool ,
636
637
) -> Result < ( u8 , u8 , u8 , bool ) , ParseError < ' i , ComponentParser :: Error > >
637
638
where
638
639
ComponentParser : ColorComponentParser < ' i > ,
@@ -646,7 +647,7 @@ where
646
647
let hue = hue_normalized_degrees / 360. ;
647
648
648
649
// Saturation and lightness are clamped to 0% ... 100%
649
- let uses_commas = arguments. try_parse ( |i| i. expect_comma ( ) ) . is_ok ( ) ;
650
+ let uses_commas = allow_comma && arguments. try_parse ( |i| i. expect_comma ( ) ) . is_ok ( ) ;
650
651
651
652
let first_percentage = component_parser. parse_percentage ( arguments) ?. max ( 0. ) . min ( 1. ) ;
652
653
0 commit comments