@@ -423,6 +423,9 @@ impl TokenSerializationType {
423423 /// so that they are not re-parsed as a single token.
424424 ///
425425 /// See https://drafts.csswg.org/css-syntax/#serialization
426+ ///
427+ /// See https://github.com/w3c/csswg-drafts/issues/4088 for the
428+ /// `DelimPercent` bits.
426429 pub fn needs_separator_when_before ( self , other : TokenSerializationType ) -> bool {
427430 use self :: TokenSerializationTypeVariants :: * ;
428431 match self . 0 {
@@ -442,17 +445,21 @@ impl TokenSerializationType {
442445 other. 0 ,
443446 Ident | Function | UrlOrBadUrl | DelimMinus | Number | Percentage | Dimension | CDC
444447 ) ,
445- DelimHash | DelimMinus | Number => matches ! (
448+ DelimHash | DelimMinus => matches ! (
446449 other. 0 ,
447450 Ident | Function | UrlOrBadUrl | DelimMinus | Number | Percentage | Dimension
448451 ) ,
452+ Number => matches ! (
453+ other. 0 ,
454+ Ident | Function | UrlOrBadUrl | DelimMinus | Number | Percentage | DelimPercent | Dimension
455+ ) ,
449456 DelimAt => matches ! ( other. 0 , Ident | Function | UrlOrBadUrl | DelimMinus ) ,
450457 DelimDotOrPlus => matches ! ( other. 0 , Number | Percentage | Dimension ) ,
451458 DelimAssorted | DelimAsterisk => matches ! ( other. 0 , DelimEquals ) ,
452459 DelimBar => matches ! ( other. 0 , DelimEquals | DelimBar | DashMatch ) ,
453460 DelimSlash => matches ! ( other. 0 , DelimAsterisk | SubstringMatch ) ,
454461 Nothing | WhiteSpace | Percentage | UrlOrBadUrl | Function | CDC | OpenParen
455- | DashMatch | SubstringMatch | DelimQuestion | DelimEquals | Other => false ,
462+ | DashMatch | SubstringMatch | DelimQuestion | DelimEquals | DelimPercent | Other => false ,
456463 }
457464 }
458465}
@@ -482,6 +489,7 @@ enum TokenSerializationTypeVariants {
482489 DelimBar , // '|'
483490 DelimSlash , // '/'
484491 DelimAsterisk , // '*'
492+ DelimPercent , // '%'
485493 Other , // anything else
486494}
487495
@@ -502,6 +510,7 @@ impl<'a> Token<'a> {
502510 Token :: Delim ( '-' ) => DelimMinus ,
503511 Token :: Delim ( '?' ) => DelimQuestion ,
504512 Token :: Delim ( '$' ) | Token :: Delim ( '^' ) | Token :: Delim ( '~' ) => DelimAssorted ,
513+ Token :: Delim ( '%' ) => DelimPercent ,
505514 Token :: Delim ( '=' ) => DelimEquals ,
506515 Token :: Delim ( '|' ) => DelimBar ,
507516 Token :: Delim ( '/' ) => DelimSlash ,
0 commit comments