/// Extend one or more modifiers of a module to create a new modifier
/// combining the ones you pass
///
/// @param {string|list} $modifiers [null] - The modifiers which you wish to combine
/// @param {string} $parent [null] - The parent module if not current one
/// @param {bool} $core [false] - Extend the core '.module' styles?
@mixin extend($modifiers: null, $parent: null, $core: false) {
  $namespaced-parent: if($moduleNamespace and $parent, $moduleNamespace + $parent, $parent);

  @if $core or not $modifiers {
    @extend .#{$namespaced-parent};
  }

  @each $modifier in $modifiers {
    @if type-of($modifier) == 'string' {
      $selector: if($parent, $namespaced-parent, $module);

      @extend [class*="#{$selector}#{$modifierGlue}"][class*="#{$modifierGlue}#{$modifier}"];
    }
    @else if type-of($modifier) == 'list' {
      $namespaced-selector: ('[class*="#{$namespaced-parent}#{$modifierGlue}"]');
      $module-selector: ('[class*="#{$module}#{$modifierGlue}"]');

      $selectors: if($parent, $namespaced-selector, $module-selector);

      @each $item in $modifier {
        $selectors: join($selectors, '[class*="#{$modifierGlue}#{$item}"]', comma);
      }

      @extend #{$selectors};
    }
  }
}

// Alias for extending entire modules
@mixin _module($module, $modifiers: null, $core: true) {
  @include extend($parent: $module, $modifiers: $modifiers, $core: $core);
}