do not strip newlines after comments in selectors
This commit is contained in:
parent
827225a143
commit
c4439c14fd
@ -219,6 +219,7 @@ impl<'a> Parser<'a> {
|
||||
'/' => {
|
||||
self.toks.next();
|
||||
let comment = self.parse_comment()?;
|
||||
self.whitespace();
|
||||
match comment.node {
|
||||
Comment::Silent => continue,
|
||||
Comment::Loud(s) => stmts.push(Stmt::Comment(s)),
|
||||
@ -346,7 +347,6 @@ impl<'a> Parser<'a> {
|
||||
return Err(("Expected selector.", tok.pos()).into());
|
||||
}
|
||||
self.parse_comment()?;
|
||||
self.whitespace();
|
||||
string.push(' ');
|
||||
}
|
||||
'{' => {
|
||||
@ -403,11 +403,12 @@ impl<'a> Parser<'a> {
|
||||
Ok(Spanned {
|
||||
node: match self.toks.next() {
|
||||
Some(Token { kind: '/', .. }) => {
|
||||
while let Some(tok) = self.toks.next() {
|
||||
while let Some(tok) = self.toks.peek() {
|
||||
if tok.kind == '\n' {
|
||||
break;
|
||||
}
|
||||
span = span.merge(tok.pos);
|
||||
self.toks.next();
|
||||
}
|
||||
|
||||
Comment::Silent
|
||||
|
@ -663,6 +663,11 @@ test!(
|
||||
"@mixin foo {\n #{if(&, 'true', 'false')} {\n color: red;\n }\n}\n\n@include foo;\n\na {\n @include foo;\n}\n",
|
||||
"false {\n color: red;\n}\n\na true {\n color: red;\n}\n"
|
||||
);
|
||||
test!(
|
||||
newline_is_preserved_when_following_comment,
|
||||
"a, // 1\nb,\nc {\n color: red;\n}\n",
|
||||
"a,\nb,\nc {\n color: red;\n}\n"
|
||||
);
|
||||
error!(
|
||||
a_n_plus_b_n_invalid_odd,
|
||||
":nth-child(ofdd) {\n color: &;\n}\n", "Error: Expected \"odd\"."
|
||||
|
Loading…
x
Reference in New Issue
Block a user