/**
 * Requires
 */
@use "sass:meta";

/**
 * Select current scope only if a given attribute is set
 * @param {string} $attribute - Attribute name, default: 'class'
 * @param {boolean} $empty - Allow empty attribute
 * @param {string} $error - Error message prefix
 * @output Wraps given content styles to apply only if the current scope element has the given attribute
 */
@mixin attr-isset($attribute: 'class', $empty: false, $error: 'attr-isset::') {
  @if meta.content-exists() != true {
    @error '#{$error}@content is required';
  }
  @if $empty {
    &[#{$attribute}] {
      @content;
    }
  } @else {
    &[#{$attribute}]:not([#{$attribute}='']) {
      @content;
    }
  }
}
