@@ -564,8 +564,8 @@ where
564564{
565565 let ( red, green, blue, uses_commas) = match_ignore_ascii_case ! { name,
566566 "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 ) ?,
569569 _ => return Err ( arguments. new_unexpected_token_error( Token :: Ident ( name. to_owned( ) . into( ) ) ) ) ,
570570 } ;
571571
@@ -633,6 +633,7 @@ fn parse_hsl_hwb<'i, 't, ComponentParser>(
633633 component_parser : & ComponentParser ,
634634 arguments : & mut Parser < ' i , ' t > ,
635635 to_rgb : impl FnOnce ( f32 , f32 , f32 ) -> ( f32 , f32 , f32 ) ,
636+ allow_comma : bool ,
636637) -> Result < ( u8 , u8 , u8 , bool ) , ParseError < ' i , ComponentParser :: Error > >
637638where
638639 ComponentParser : ColorComponentParser < ' i > ,
@@ -646,7 +647,7 @@ where
646647 let hue = hue_normalized_degrees / 360. ;
647648
648649 // 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 ( ) ;
650651
651652 let first_percentage = component_parser. parse_percentage ( arguments) ?. max ( 0. ) . min ( 1. ) ;
652653
0 commit comments