diff --git a/src/atrule/mixin.rs b/src/atrule/mixin.rs index 8c5bf0e..716a411 100644 --- a/src/atrule/mixin.rs +++ b/src/atrule/mixin.rs @@ -4,7 +4,7 @@ use codemap::Spanned; use peekmore::{PeekMore, PeekMoreIterator}; -use super::eat_stmts; +use super::ruleset_eval; use crate::args::{eat_call_args, eat_func_args, CallArgs, FuncArgs}; use crate::atrule::AtRule; @@ -223,18 +223,28 @@ pub(crate) fn eat_include>( devour_whitespace(toks); - let content = if let Some(tok) = toks.peek() { + let mut content = Vec::new(); + + if let Some(tok) = toks.peek() { if tok.kind == '{' { toks.next(); - eat_stmts(toks, &mut scope.clone(), super_selector, false)? + ruleset_eval( + toks, + &mut scope.clone(), + super_selector, + false, + &mut content, + )?; } else if has_content { - eat_stmts(toks, &mut scope.clone(), super_selector, false)? - } else { - Vec::new() + ruleset_eval( + toks, + &mut scope.clone(), + super_selector, + false, + &mut content, + )?; } - } else { - Vec::new() - }; + } let mixin = scope.get_mixin(name)?; diff --git a/tests/mixins.rs b/tests/mixins.rs index 221148f..09c9b31 100644 --- a/tests/mixins.rs +++ b/tests/mixins.rs @@ -199,3 +199,8 @@ test!( "@mixin foo($a_b) {\n color: $a-b;\n color: $a_b;\n}\na {\n @include foo($a_b: a);\n @include foo($a-b: a);\n}\n", "a {\n color: a;\n color: a;\n color: a;\n color: a;\n}\n" ); +test!( + control_flow_in_content, + "@mixin foo {\n @content;\n}\n\na {\n @include foo {@if true {color: red;}}\n}\n", + "a {\n color: red;\n}\n" +);