do not strip whitespace after var in call args
This commit is contained in:
parent
c921a54edf
commit
71495cd03b
13
src/args.rs
13
src/args.rs
@ -8,8 +8,8 @@ use crate::error::SassResult;
|
||||
use crate::scope::Scope;
|
||||
use crate::selector::Selector;
|
||||
use crate::utils::{
|
||||
devour_whitespace, devour_whitespace_or_comment, eat_ident, read_until_closing_paren,
|
||||
read_until_closing_quote, read_until_closing_square_brace,
|
||||
devour_whitespace, devour_whitespace_or_comment, eat_ident, eat_ident_no_interpolation,
|
||||
read_until_closing_paren, read_until_closing_quote, read_until_closing_square_brace,
|
||||
};
|
||||
use crate::value::Value;
|
||||
use crate::Token;
|
||||
@ -298,8 +298,6 @@ pub(crate) fn eat_func_args<I: Iterator<Item = Token>>(
|
||||
|
||||
pub(crate) fn eat_call_args<I: Iterator<Item = Token>>(
|
||||
toks: &mut PeekMoreIterator<I>,
|
||||
scope: &Scope,
|
||||
super_selector: &Selector,
|
||||
) -> SassResult<CallArgs> {
|
||||
let mut args: HashMap<CallArg, Vec<Token>> = HashMap::new();
|
||||
devour_whitespace_or_comment(toks)?;
|
||||
@ -310,8 +308,8 @@ pub(crate) fn eat_call_args<I: Iterator<Item = Token>>(
|
||||
match toks.peek().unwrap().kind {
|
||||
'$' => {
|
||||
let Token { pos, .. } = toks.next().unwrap();
|
||||
let v = eat_ident(toks, scope, super_selector)?;
|
||||
devour_whitespace_or_comment(toks)?;
|
||||
let v = eat_ident_no_interpolation(toks, false)?;
|
||||
let whitespace = devour_whitespace_or_comment(toks)?;
|
||||
if toks.peek().unwrap().kind == ':' {
|
||||
toks.next();
|
||||
name = v.node;
|
||||
@ -324,6 +322,9 @@ pub(crate) fn eat_call_args<I: Iterator<Item = Token>>(
|
||||
current_pos += len;
|
||||
tok
|
||||
}));
|
||||
if whitespace {
|
||||
val.push(Token::new(pos, ' '));
|
||||
}
|
||||
name.clear();
|
||||
}
|
||||
}
|
||||
|
@ -523,11 +523,7 @@ impl Value {
|
||||
Err(_) => match GLOBAL_FUNCTIONS.get(&s.replace('_', "-")) {
|
||||
Some(f) => {
|
||||
return Ok(IntermediateValue::Value(Spanned {
|
||||
node: f.0(
|
||||
eat_call_args(toks, scope, super_selector)?,
|
||||
scope,
|
||||
super_selector,
|
||||
)?,
|
||||
node: f.0(eat_call_args(toks)?, scope, super_selector)?,
|
||||
span,
|
||||
}))
|
||||
}
|
||||
@ -541,13 +537,12 @@ impl Value {
|
||||
"url" => match try_eat_url(toks, scope, super_selector)? {
|
||||
Some(val) => s = val,
|
||||
None => s.push_str(
|
||||
&eat_call_args(toks, scope, super_selector)?
|
||||
&eat_call_args(toks)?
|
||||
.to_css_string(scope, super_selector)?,
|
||||
),
|
||||
},
|
||||
_ => s.push_str(
|
||||
&eat_call_args(toks, scope, super_selector)?
|
||||
.to_css_string(scope, super_selector)?,
|
||||
&eat_call_args(toks)?.to_css_string(scope, super_selector)?,
|
||||
),
|
||||
}
|
||||
return Ok(IntermediateValue::Value(Spanned {
|
||||
@ -558,11 +553,7 @@ impl Value {
|
||||
},
|
||||
};
|
||||
Ok(IntermediateValue::Value(
|
||||
func.eval(
|
||||
eat_call_args(toks, scope, super_selector)?,
|
||||
scope,
|
||||
super_selector,
|
||||
)?
|
||||
func.eval(eat_call_args(toks)?, scope, super_selector)?
|
||||
.span(span),
|
||||
))
|
||||
}
|
||||
|
@ -30,3 +30,8 @@ test!(
|
||||
"$da: a;\n\n@mixin foo($x: $da) {\n color: $x;\n}\n$da: b;\n\na {\n @include foo();\n}\n",
|
||||
"a {\n color: b;\n}\n"
|
||||
);
|
||||
test!(
|
||||
variable_being_subtracted,
|
||||
"$index: 1;\n\n@function foo($a) {\n @return $a;\n}\n\na {\n color: foo($index - 1);\n}\n",
|
||||
"a {\n color: 0;\n}\n"
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user