diff --git a/lib/src/visitor/perform.dart b/lib/src/visitor/perform.dart index b79ec0d4..d48087a6 100644 --- a/lib/src/visitor/perform.dart +++ b/lib/src/visitor/perform.dart @@ -60,6 +60,13 @@ class _PerformVisitor /// The current selector, if any. CssValue _selector; + /// The value of [_selector] outside an `@at-root` statement that excludes + /// style rules. + /// + /// This is separate from [_selector] because `&` can see it but parent + /// resolution cannot. + CssValue _selectorOutsideAtRoot; + /// The current media queries, if any. List _mediaQueries; @@ -228,6 +235,16 @@ class _PerformVisitor _parent = oldParent; }; + if (query.excludesStyleRules) { + var innerScope = scope; + scope = (callback) { + var oldSelectorOutsideAtRoot = _selectorOutsideAtRoot; + _selectorOutsideAtRoot = _selector ?? _selectorOutsideAtRoot; + _withSelector(null, () => innerScope(callback)); + _selectorOutsideAtRoot = oldSelectorOutsideAtRoot; + }; + } + if (query.excludesMedia) { var innerScope = scope; scope = (callback) => _withMediaQueries(null, () => innerScope(callback)); @@ -1203,8 +1220,9 @@ class _PerformVisitor } Value visitSelectorExpression(SelectorExpression node) { - if (_selector == null) return sassNull; - return _selector.value.asSassList; + var selector = _selector ?? _selectorOutsideAtRoot; + if (selector == null) return sassNull; + return selector.value.asSassList; } SassString visitStringExpression(StringExpression node) =>