From 1761af0a01d7ba30b9c34ad139c908122f2f8074 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Sun, 26 Jan 2020 17:28:39 -0500 Subject: [PATCH] Handle toplevel @include --- src/lib.rs | 3 +++ tests/main.rs | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index a662857..9cdead1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -361,6 +361,9 @@ impl<'a> StyleSheetParser<'a> { }; rules.push(Stmt::MultilineComment(comment)); } + TokenKind::AtRule(AtRuleKind::Include) => { + rules.extend(eat_include(&mut self.lexer, &self.global_scope, &Selector(Vec::new())).unwrap_or_else(|e| self.error(e.0, &e.1))) + } TokenKind::AtRule(AtRuleKind::Import) => { let Token { pos, .. } = self .lexer diff --git a/tests/main.rs b/tests/main.rs index a03573c..ca0c5da 100644 --- a/tests/main.rs +++ b/tests/main.rs @@ -664,6 +664,11 @@ mod test_mixins { "@mixin a($a) {\n color: $a;\n}\nd {\n @include a($a/*foo*/: red);\n}\n", "d {\n color: red;\n}\n" ); + test!( + toplevel_include, + "@mixin a {\n a {\n color: red;\n }\n}\n\n@include a;\n", + "a {\n color: red;\n}\n" + ); } #[cfg(test)]