////
/// @group Selectors
/// @link http://sass-lang.com/documentation/Sass/Script/Functions.html#selector_functions
////
@use "sass:selector";

/// Add selector to root (requires Sass 3.4+)
/// @param {String} $selector - Selector to add to root
///
/// @example scss
///   .foo {
///     @include root-add(a) {
///       content: 'a.foo';
///     }
///
///     @include root-add('.bar') {
///       content: '.foo.bar';
///     }
///   }
///
@mixin root-add($selector) {
  @at-root #{selector.append($selector, &)} {
    @content;
  }
}

/// Prepend selector (requires Sass 3.4+)
/// @param {String} $selector - Selector to insert before root
///
/// @example scss
///   .foo {
///     @include root-before(a) {
///       content: 'a .foo';
///     }
///
///     @include root-before('.bar') {
///       content: '.bar .foo';
///     }
///   }
///
@mixin root-before($selector) {
  @at-root #{selector.nest($selector, &)} {
    @content;
  }
}
