Allow variable declarations in at rules
This commit is contained in:
parent
b85b122e3d
commit
7923d096a7
@ -263,7 +263,8 @@ fn eat_unknown_atrule_body<I: Iterator<Item = Token>>(
|
|||||||
super_selector: &Selector,
|
super_selector: &Selector,
|
||||||
) -> SassResult<Vec<Stmt>> {
|
) -> SassResult<Vec<Stmt>> {
|
||||||
let mut stmts = Vec::new();
|
let mut stmts = Vec::new();
|
||||||
while let Some(expr) = eat_expr(toks, scope, super_selector)? {
|
let mut scope = scope.clone();
|
||||||
|
while let Some(expr) = eat_expr(toks, &scope, super_selector)? {
|
||||||
match expr {
|
match expr {
|
||||||
Expr::AtRule(a) => stmts.push(Stmt::AtRule(a)),
|
Expr::AtRule(a) => stmts.push(Stmt::AtRule(a)),
|
||||||
Expr::Style(s) => stmts.push(Stmt::Style(*s)),
|
Expr::Style(s) => stmts.push(Stmt::Style(*s)),
|
||||||
@ -273,16 +274,15 @@ fn eat_unknown_atrule_body<I: Iterator<Item = Token>>(
|
|||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
Expr::Selector(selector) => {
|
Expr::Selector(selector) => {
|
||||||
let rules = eat_unknown_atrule_body(toks, scope, &super_selector.zip(&selector))?;
|
let rules = eat_unknown_atrule_body(toks, &scope, &super_selector.zip(&selector))?;
|
||||||
stmts.push(Stmt::RuleSet(RuleSet {
|
stmts.push(Stmt::RuleSet(RuleSet {
|
||||||
super_selector: super_selector.clone(),
|
super_selector: super_selector.clone(),
|
||||||
selector,
|
selector,
|
||||||
rules,
|
rules,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
Expr::VariableDecl(..) => {
|
Expr::VariableDecl(name, val) => {
|
||||||
todo!()
|
scope.insert_var(&name, *val);
|
||||||
// self.scope.insert_var(&name, *val);
|
|
||||||
}
|
}
|
||||||
Expr::MultilineComment(s) => stmts.push(Stmt::MultilineComment(s)),
|
Expr::MultilineComment(s) => stmts.push(Stmt::MultilineComment(s)),
|
||||||
}
|
}
|
||||||
|
10
tests/for.rs
10
tests/for.rs
@ -23,3 +23,13 @@ test!(
|
|||||||
"@for $i from 3 to 1 {\n a {\n color: $i;\n }\n}\n",
|
"@for $i from 3 to 1 {\n a {\n color: $i;\n }\n}\n",
|
||||||
"a {\n color: 3;\n}\n\na {\n color: 2;\n}\n"
|
"a {\n color: 3;\n}\n\na {\n color: 2;\n}\n"
|
||||||
);
|
);
|
||||||
|
test!(
|
||||||
|
for_var_through_var,
|
||||||
|
"$a: 1;\n$b: 3;\n@for $x from $a through $b {\n div {\n color: $x;\n }\n}\n",
|
||||||
|
"div {\n color: 1;\n}\n\ndiv {\n color: 2;\n}\n\ndiv {\n color: 3;\n}\n"
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
for_var_decl,
|
||||||
|
"@for $x from 1 to 3 {\n $limit: $x;\n\n a {\n color: $limit;\n }\n}\n",
|
||||||
|
"a {\n color: 1;\n}\n\na {\n color: 2;\n}\n"
|
||||||
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user