interpolation of strings in idents is literal

This commit is contained in:
ConnorSkees 2020-04-20 12:12:39 -04:00
parent 29886d6845
commit a6b61082fe
3 changed files with 13 additions and 11 deletions

View File

@ -525,9 +525,10 @@ pub(crate) fn eat_ident<I: Iterator<Item = Token>>(
if kind == &'{' { if kind == &'{' {
toks.next(); toks.next();
text.push_str( text.push_str(
&parse_interpolation(toks, scope, super_selector)? &match parse_interpolation(toks, scope, super_selector)?.node {
.node Value::Ident(s, ..) => s,
.to_css_string(span)?, v => v.to_css_string(span)?,
},
); );
} else { } else {
return Err(("Expected identifier.", *pos).into()); return Err(("Expected identifier.", *pos).into());

View File

@ -165,14 +165,10 @@ impl Value {
let mut buf = String::with_capacity(string.len()); let mut buf = String::with_capacity(string.len());
for c in string.chars() { for c in string.chars() {
match c { match c {
// TODO: figure out what is going on here '\n' => {
// This is adapted from the original dart-sass buf.push(' ');
// code, but in the spec tests it seems that after_newline = true;
// newlines are not actually treated like this. }
// '\n' => {
// buf.push(' ');
// after_newline = true;
// }
' ' => { ' ' => {
if !after_newline { if !after_newline {
buf.push(' '); buf.push(' ');

View File

@ -53,3 +53,8 @@ test!(
"a {\n color: \"#{#{\"\\a\"}}\";\n}\n", "a {\n color: \"#{#{\"\\a\"}}\";\n}\n",
"a {\n color: \"\\a\";\n}\n" "a {\n color: \"\\a\";\n}\n"
); );
test!(
interpolated_quoted_newline,
"a {\n color: #{\"\\a\"};\n}\n",
"a {\n color: ;\n}\n"
);