Consume whitespace after variable value

This commit is contained in:
ConnorSkees 2020-01-17 21:03:01 -05:00
parent cee40858ee
commit eaf1e8eb96
2 changed files with 5 additions and 15 deletions

View File

@ -714,6 +714,11 @@ mod css_variables {
"$a: 1px;\n$b: 1 $a;\na {\n height: $b;\n}\n",
"a {\n height: 1 1px;\n}\n"
);
test!(
eats_whitespace_after_variable_value,
"a {\n b {\n $c: red;\n }\n color: red;\n}\n",
"a {\n color: red;\n}\n"
);
}
#[cfg(test)]

View File

@ -75,21 +75,6 @@ pub fn eat_variable_value<I: Iterator<Item = Token>>(
_ => iter2.push(tok),
};
}
Ok(iter2)
}
pub fn eat_variable_value_ref<'a, I: Iterator<Item = &'a Token>>(
toks: &mut Peekable<I>,
scope: &Scope,
) -> Result<Vec<Token>, (Pos, &'static str)> {
devour_whitespace(toks);
let iter1 = toks.take_while(|x| x.kind != TokenKind::Symbol(Symbol::SemiColon));
let mut iter2 = Vec::new();
for tok in iter1 {
match tok.kind {
TokenKind::Variable(ref name) => iter2.extend(deref_variable(name, scope)),
_ => iter2.push(tok.clone()),
};
}
Ok(iter2)
}