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 == &'{' {
toks.next();
text.push_str(
&parse_interpolation(toks, scope, super_selector)?
.node
.to_css_string(span)?,
&match parse_interpolation(toks, scope, super_selector)?.node {
Value::Ident(s, ..) => s,
v => v.to_css_string(span)?,
},
);
} else {
return Err(("Expected identifier.", *pos).into());

View File

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

View File

@ -53,3 +53,8 @@ test!(
"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"
);