From 3c756f661d919178ee36c6f5c3449b68977c7335 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Fri, 10 Jul 2020 21:19:11 -0400 Subject: [PATCH] unconditionally exit mixin scope --- src/parse/mixin.rs | 4 ++-- tests/mixins.rs | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/parse/mixin.rs b/src/parse/mixin.rs index 4add13a..610099c 100644 --- a/src/parse/mixin.rs +++ b/src/parse/mixin.rs @@ -145,10 +145,10 @@ impl<'a> Parser<'a> { .parse()?; self.content.pop(); + self.scopes.exit_scope(); + if declared_at_root { mem::swap(self.scopes, self.content_scopes); - } else { - self.scopes.exit_scope(); } Ok(body) diff --git a/tests/mixins.rs b/tests/mixins.rs index 99bdf5a..35dc6ec 100644 --- a/tests/mixins.rs +++ b/tests/mixins.rs @@ -426,3 +426,26 @@ test!( }", "a {\n color: 1rem;\n}\n" ); +test!( + can_access_global_variables_set_after_other_include, + "$x: true; + + @mixin foobar() { + @if $x { + $x: false !global; + color: foo; + } + + @else { + $x: true !global; + color: bar; + } + } + + a { + @include foobar(); + $x: true !global; + @include foobar(); + }", + "a {\n color: foo;\n color: foo;\n}\n" +);