properly handle interpolation in selectors

This commit is contained in:
ConnorSkees 2020-03-30 02:30:44 -04:00
parent 57a704172f
commit 31ec0cc7f8
3 changed files with 8 additions and 4 deletions

View File

@ -600,9 +600,8 @@ pub(crate) fn eat_expr<I: Iterator<Item = Token>>(
}
'#' => {
values.push(toks.next().unwrap());
let next = toks.next().unwrap();
values.push(next);
if next.kind == '{' {
if toks.peek().unwrap().kind == '{' {
values.push(toks.next().unwrap());
values.extend(eat_interpolation(toks));
}
}

View File

@ -269,7 +269,7 @@ impl<'a> SelectorParser<'a> {
}
'#' => {
tokens.next();
if tokens.peek().unwrap().kind == '{' {
if tokens.peek().is_some() && tokens.peek().unwrap().kind == '{' {
tokens.next();
self.is_interpolated = true;
self.tokens_to_selectors(

View File

@ -305,3 +305,8 @@ test!(
// );
test!(allows_id_start_with_number, "#2foo {\n color: red;\n}\n");
test!(allows_id_only_number, "#2 {\n color: red;\n}\n");
test!(
id_interpolation,
"$zzz: zzz;\n##{$zzz} {\n a: b;\n}\n",
"#zzz {\n a: b;\n}\n"
);