diff --git a/src/lib.rs b/src/lib.rs index fb85e403..066b28da 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22488,6 +22488,23 @@ mod tests { "#, "@layer{.bar{color:red}}", ); + minify_test( + r#" + @layer foo\20 bar, baz; + "#, + "@layer foo\\ bar,baz;", + ); + minify_test( + r#" + @layer one.two\20 three\#four\.five { + .bar { + color: red; + } + } + "#, + "@layer one.two\\ three\\#four\\.five{.bar{color:red}}", + ); + error_test("@layer;", ParserError::UnexpectedToken(Token::Semicolon)); error_test("@layer foo, bar {};", ParserError::AtRuleBodyInvalid); minify_test("@import 'test.css' layer;", "@import \"test.css\" layer;"); @@ -22496,6 +22513,10 @@ mod tests { "@import 'test.css' layer(foo.bar);", "@import \"test.css\" layer(foo.bar);", ); + minify_test( + "@import 'test.css' layer(foo\\20 bar);", + "@import \"test.css\" layer(foo\\ bar);", + ); error_test( "@import 'test.css' layer(foo, bar) {};", ParserError::UnexpectedToken(Token::Comma), diff --git a/src/rules/layer.rs b/src/rules/layer.rs index 0cbdeb2b..0a2a01f9 100644 --- a/src/rules/layer.rs +++ b/src/rules/layer.rs @@ -72,7 +72,7 @@ impl<'i> ToCss for LayerName<'i> { dest.write_char('.')?; } - dest.write_str(name)?; + serialize_identifier(name, dest)?; } Ok(())