add unit field to ident eating
This commit is contained in:
parent
9790846c99
commit
e07ceda8c7
@ -616,7 +616,7 @@ pub(crate) fn eat_expr<I: Iterator<Item = Token>>(
|
||||
values.push(toks.next().unwrap());
|
||||
continue;
|
||||
}
|
||||
let name = eat_ident_no_interpolation(toks)?;
|
||||
let name = eat_ident_no_interpolation(toks, false)?;
|
||||
devour_whitespace(toks);
|
||||
if toks.peek().unwrap().kind == ':' {
|
||||
toks.next();
|
||||
|
@ -258,7 +258,7 @@ impl Selector {
|
||||
inner.push(match tok.kind {
|
||||
_ if is_selector_name_char(tok.kind) => {
|
||||
inner.push(SelectorKind::Element(
|
||||
eat_ident_no_interpolation(&mut iter)?.node,
|
||||
eat_ident_no_interpolation(&mut iter, false)?.node,
|
||||
));
|
||||
continue;
|
||||
}
|
||||
@ -269,14 +269,14 @@ impl Selector {
|
||||
'.' => {
|
||||
iter.next();
|
||||
inner.push(SelectorKind::Class(
|
||||
eat_ident_no_interpolation(&mut iter)?.node,
|
||||
eat_ident_no_interpolation(&mut iter, false)?.node,
|
||||
));
|
||||
continue;
|
||||
}
|
||||
'#' => {
|
||||
iter.next();
|
||||
inner.push(SelectorKind::Id(
|
||||
eat_ident_no_interpolation(&mut iter)?.node,
|
||||
eat_ident_no_interpolation(&mut iter, false)?.node,
|
||||
));
|
||||
continue;
|
||||
}
|
||||
@ -284,7 +284,7 @@ impl Selector {
|
||||
iter.next();
|
||||
is_invisible = true;
|
||||
inner.push(SelectorKind::Placeholder(
|
||||
eat_ident_no_interpolation(&mut iter)?.node,
|
||||
eat_ident_no_interpolation(&mut iter, false)?.node,
|
||||
));
|
||||
continue;
|
||||
}
|
||||
@ -371,7 +371,7 @@ impl Selector {
|
||||
false
|
||||
};
|
||||
if is_selector_name_char(toks.peek().unwrap().kind) {
|
||||
let name = eat_ident_no_interpolation(toks)?.node;
|
||||
let name = eat_ident_no_interpolation(toks, false)?.node;
|
||||
Ok(
|
||||
if toks.peek().is_some() && toks.peek().unwrap().kind == '(' {
|
||||
toks.next();
|
||||
|
@ -533,6 +533,7 @@ pub(crate) fn eat_ident<I: Iterator<Item = Token>>(
|
||||
|
||||
pub(crate) fn eat_ident_no_interpolation<I: Iterator<Item = Token>>(
|
||||
toks: &mut Peekable<I>,
|
||||
unit: bool,
|
||||
) -> SassResult<Spanned<String>> {
|
||||
let mut span = toks.peek().unwrap().pos();
|
||||
let mut text = String::new();
|
||||
@ -542,7 +543,7 @@ pub(crate) fn eat_ident_no_interpolation<I: Iterator<Item = Token>>(
|
||||
if toks.peek().unwrap().kind == '-' {
|
||||
toks.next();
|
||||
text.push('-');
|
||||
text.push_str(&ident_body(toks, false, span)?.node);
|
||||
text.push_str(&ident_body(toks, unit, span)?.node);
|
||||
return Ok(Spanned { node: text, span });
|
||||
}
|
||||
}
|
||||
@ -561,7 +562,7 @@ pub(crate) fn eat_ident_no_interpolation<I: Iterator<Item = Token>>(
|
||||
return Err(("Expected identifier.", first.pos()).into());
|
||||
}
|
||||
|
||||
let body = ident_body(toks, false, span)?;
|
||||
let body = ident_body(toks, unit, span)?;
|
||||
span = span.merge(body.span);
|
||||
text.push_str(&body.node);
|
||||
Ok(Spanned { node: text, span })
|
||||
|
@ -607,7 +607,7 @@ impl Value {
|
||||
let unit = if let Some(tok) = toks.peek() {
|
||||
match tok.kind {
|
||||
'a'..='z' | 'A'..='Z' | '_' => {
|
||||
let u = eat_ident(toks, scope, super_selector)?;
|
||||
let u = eat_ident_no_interpolation(toks, true)?;
|
||||
span = span.merge(u.span);
|
||||
Unit::from(&u.node)
|
||||
}
|
||||
@ -708,7 +708,7 @@ impl Value {
|
||||
}
|
||||
'$' => {
|
||||
toks.next();
|
||||
let val = eat_ident_no_interpolation(toks)?;
|
||||
let val = eat_ident_no_interpolation(toks, false)?;
|
||||
Ok(IntermediateValue::Value(Spanned {
|
||||
node: scope.get_var(val.clone())?.node,
|
||||
span: val.span,
|
||||
|
Loading…
x
Reference in New Issue
Block a user