diff --git a/src/lib.rs b/src/lib.rs index bf70fe5..e60f051 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -600,9 +600,8 @@ pub(crate) fn eat_expr>( } '#' => { 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)); } } diff --git a/src/selector.rs b/src/selector.rs index 280dd3f..836915c 100644 --- a/src/selector.rs +++ b/src/selector.rs @@ -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( diff --git a/tests/selectors.rs b/tests/selectors.rs index 840dcfd..a910d7d 100644 --- a/tests/selectors.rs +++ b/tests/selectors.rs @@ -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" +);