Handle comments between selectors

This commit is contained in:
ConnorSkees 2020-01-26 16:55:06 -05:00
parent a8ebc91702
commit 934f9d860d
2 changed files with 7 additions and 2 deletions

View File

@ -1,5 +1,5 @@
use crate::common::{Scope, Symbol}; use crate::common::{Scope, Symbol};
use crate::utils::{devour_whitespace, eat_interpolation, IsWhitespace}; use crate::utils::{devour_whitespace, devour_whitespace_or_comment, eat_interpolation, IsWhitespace};
use crate::{Token, TokenKind}; use crate::{Token, TokenKind};
use std::fmt::{self, Display}; use std::fmt::{self, Display};
use std::iter::Peekable; use std::iter::Peekable;
@ -232,7 +232,7 @@ impl<'a> SelectorParser<'a> {
} }
fn consume_selector(&mut self, tokens: &'_ mut Peekable<IntoIter<Token>>) { fn consume_selector(&mut self, tokens: &'_ mut Peekable<IntoIter<Token>>) {
if devour_whitespace(tokens) { if devour_whitespace_or_comment(tokens) {
if let Some(Token { if let Some(Token {
kind: TokenKind::Symbol(Symbol::Comma), kind: TokenKind::Symbol(Symbol::Comma),
.. ..

View File

@ -294,6 +294,11 @@ mod test_selectors {
" a > b , c ~ d e .f #g :h i.j [ k ] { color: red }", " a > b , c ~ d e .f #g :h i.j [ k ] { color: red }",
"a > b, c ~ d e .f #g :h i.j [k] {\n color: red;\n}\n" "a > b, c ~ d e .f #g :h i.j [k] {\n color: red;\n}\n"
); );
test!(
comment_between_selectors,
"a /* foo */ b {\n color: red;\n}\n",
"a b {\n color: red;\n}\n"
);
} }
#[cfg(test)] #[cfg(test)]